As it turns out ChatGPT has quite a few problems. So for the time being I am only using it for things I already have skills to which to verify the veracity of what it outputs. That puts the ChatGPT And Me series of posts on indefinite hold. I am still playing around with ChatGPT for programming uses, however the progress is slow as I decided to restructure the Learning a new Programming Language with ChatGPT more than once and thus did not spend the little time I have outside of work on rewrite of the site.
So for the three new projects I 'launched' in February of last year one on hold, two I'm still working on. News years resolution: post progress reports in some timely manner. I am focused on relaunching the site as the priority before I work on any other personal projects. So for now that is my focus. posted by dharh 5:04 PM Jan 16th, 2024
Me: I have a website called "in deep thought" where I have the slogan "a little order in the chaos where the mind dwells". It is a blog that covers a wide variety of topics such as computers, programming, technology, math, physics, history, philosophy, geography, geology, politics, gaming etc. I am developing a new series of articles called "ChatGPT and Me" where I want to show conversations I have with you and discuss how well the conversations were and also compare differences between gpt3 and gpt4. This will be the first of those conversations.
GPT-4: Hello! I'm thrilled to be a part of your "ChatGPT and Me" series on your "In Deep Thought" website. It's an honor to help you explore various topics and engage in thought-provoking conversations. As a GPT-4 model, I hope to provide valuable insights and information. To get started, please feel free to ask any questions or bring up any topics you'd like to discuss. Me: Please give me the starting summary I should put on the first article in this series. GPT-4: Title: ChatGPT and Me: Exploring the Boundaries of AI Conversations Summary: In this inaugural article of the "ChatGPT and Me" series, we embark on a journey to explore the capabilities and limitations of OpenAI's GPT-4 language model. Through engaging conversations spanning diverse topics such as technology, science, history, and philosophy, we aim to uncover the improvements in GPT-4 over its predecessor, GPT-3, while examining the nuances of human-AI interactions. Join us as we delve into the realm of artificial intelligence and ponder its implications for our rapidly evolving world. Me: While I have my own list of topics for our conversations give me list of topics that might best cover the range of topics the website covers as well as diving deep into ChatGPT and its implications on the world. GTP-4: Here's a list of potential topics that cover the breadth of subjects on your website and highlight the capabilities and implications of ChatGPT:
These topics not only encompass the range of subjects covered on your website but also provide opportunities to dive deep into the workings of ChatGPT and its potential consequences for our world. Me: Expand on the summary you gave into multiple paragraphs and also include summary of the topics you gave for discussion. GPT-4: Title: ChatGPT and Me: Exploring the Boundaries of AI Conversations Introduction: Welcome to the first article in our "ChatGPT and Me" series, where we embark on an intellectual adventure, delving into the capabilities and limitations of OpenAI's GPT-4 language model. As we engage in stimulating conversations spanning a wide array of topics, we aim to uncover the improvements in GPT-4 over its predecessor, GPT-3, and scrutinize the nuances of human-AI interactions. Throughout this series, we will contemplate the implications of artificial intelligence on our rapidly evolving world and discuss its potential to shape the future of human knowledge and creativity. Topic Summaries:
As we navigate through these diverse topics, we hope to provide a comprehensive understanding of ChatGPT and its far-reaching implications. Join us on this fascinating journey as we explore the frontiers of artificial intelligence and ponder the potential it holds for shaping the future of human endeavor. Me: Add paragraphs talking about topics that GPT came up with and topics that I came up with. GPT-4: In this "ChatGPT and Me" series, we will be exploring a rich assortment of topics suggested by both the GPT-4 model and by you, the author. Our aim is to create a balanced and engaging dialogue, demonstrating the power of AI in generating thought-provoking discussions while also showcasing your unique perspective and ideas. Topics Generated by GPT-4: The topics proposed by the GPT-4 model span a wide range of subjects, from the evolution of AI language models to AI's impact on everyday life. These topics were specifically selected to reflect the breadth of subjects covered on your "In Deep Thought" website and to provide a comprehensive understanding of ChatGPT and its implications. By exploring these topics, we can dive deep into the world of AI, its capabilities, and its potential consequences for various fields. Topics Suggested by You: The topics you have chosen to discuss will play a crucial role in shaping the series, as they reflect your unique perspective and interests. By incorporating your ideas, we can ensure that the conversations in this series are not only informative but also engaging and relevant to your audience. The topics you bring forth will allow us to dive deeper into the world of AI while maintaining the essence of your website's thematic focus. Together, the combination of GPT-4-generated topics and your hand-picked subjects will create a dynamic and captivating series. The collaboration between AI-generated ideas and your own input will result in a stimulating and well-rounded discussion. Through this partnership, we can demonstrate the true potential of AI in fostering meaningful conversations and driving human creativity. As we traverse these topics together, we hope to provide your readers with a captivating exploration of the ever-expanding world of artificial intelligence, igniting curiosity and fostering a deeper understanding of the role AI can play in shaping our future. Me: Change that to my perspective not your perspective GPT-4: In the "ChatGPT and Me" series, we will be exploring a rich assortment of topics suggested by both the GPT-4 model and by me, the author. My aim is to create a balanced and engaging dialogue, demonstrating the power of AI in generating thought-provoking discussions while also showcasing my unique perspective and ideas. Topics Generated by GPT-4: The topics proposed by the GPT-4 model span a wide range of subjects, from the evolution of AI language models to AI's impact on everyday life. These topics were specifically selected to reflect the breadth of subjects covered on my "In Deep Thought" website and to provide a comprehensive understanding of ChatGPT and its implications. By exploring these topics, I can dive deep into the world of AI, its capabilities, and its potential consequences for various fields. Topics Suggested by Me: The topics I have chosen to discuss will play a crucial role in shaping the series, as they reflect my unique perspective and interests. By incorporating my ideas, I can ensure that the conversations in this series are not only informative but also engaging and relevant to my audience. The topics I bring forth will allow me to delve deeper into the world of AI while maintaining the essence of my website's thematic focus. Together, the combination of GPT-4-generated topics and my hand-picked subjects will create a dynamic and captivating series. The collaboration between AI-generated ideas and my own input will result in a stimulating and well-rounded discussion. Through this partnership, I can demonstrate the true potential of AI in fostering meaningful conversations and driving human creativity. As I traverse these topics with ChatGPT, I hope to provide my readers with a captivating exploration of the ever-expanding world of artificial intelligence, igniting curiosity and fostering a deeper understanding of the role AI can play in shaping our future. Me: Incorporate everything into a single article. You can be vague on the topics that I will come up with on my own. GPT-4: Title: ChatGPT and Me: Exploring the Boundaries of AI Conversations Introduction: Welcome to the first article in our "ChatGPT and Me" series, where I embark on an intellectual adventure, delving into the capabilities and limitations of OpenAI's GPT-4 language model. As I engage in stimulating conversations spanning a wide array of topics, I aim to uncover the improvements in GPT-4 over its predecessor, GPT-3, and scrutinize the nuances of human-AI interactions. Throughout this series, I will contemplate the implications of artificial intelligence on our rapidly evolving world and discuss its potential to shape the future of human knowledge and creativity. Topics Generated by GPT-4: The topics proposed by the GPT-4 model span a wide range of subjects, from the evolution of AI language models to AI's impact on everyday life. These topics were specifically selected to reflect the breadth of subjects covered on my "In Deep Thought" website and to provide a comprehensive understanding of ChatGPT and its implications. By exploring these topics, I can dive deep into the world of AI, its capabilities, and its potential consequences for various fields. Topics Suggested by Me: In addition to the topics proposed by GPT-4, I will be introducing several subjects of my own choosing, reflecting my unique perspective and interests. By incorporating my ideas, I can ensure that the conversations in this series are not only informative but also engaging and relevant to my audience. The topics I bring forth will allow me to delve deeper into the world of AI while maintaining the essence of my website's thematic focus. Together, the combination of GPT-4-generated topics and my hand-picked subjects will create a dynamic and captivating series. The collaboration between AI-generated ideas and my own input will result in a stimulating and well-rounded discussion. Through this partnership, I can demonstrate the true potential of AI in fostering meaningful conversations and driving human creativity. As I traverse these topics with ChatGPT, I hope to provide my readers with a captivating exploration of the ever-expanding world of artificial intelligence, igniting curiosity and fostering a deeper understanding of the role AI can play in shaping our future. In the upcoming articles, I will share detailed conversations I have with ChatGPT, showcasing both its capabilities and limitations. Through these dialogues, I hope to spark thought-provoking discussions around the themes presented and provide valuable insights into the world of AI. I invite you to join me on this fascinating journey as we explore the frontiers of artificial intelligence and ponder the potential it holds for shaping the future of human endeavor. Stay tuned for the next installment of the "ChatGPT and Me" series! Me: Add your list of topics to the article GPT-4: Title: ChatGPT and Me: Exploring the Boundaries of AI Conversations Introduction: Welcome to the first article in our "ChatGPT and Me" series, where I embark on an intellectual adventure, delving into the capabilities and limitations of OpenAI's GPT-4 language model. As I engage in stimulating conversations spanning a wide array of topics, I aim to uncover the improvements in GPT-4 over its predecessor, GPT-3, and scrutinize the nuances of human-AI interactions. Throughout this series, I will contemplate the implications of artificial intelligence on our rapidly evolving world and discuss its potential to shape the future of human knowledge and creativity. Topics Generated by GPT-4:
These topics were specifically selected to reflect the breadth of subjects covered on my "In Deep Thought" website and to provide a comprehensive understanding of ChatGPT and its implications. By exploring these topics, I can dive deep into the world of AI, its capabilities, and its potential consequences for various fields. Topics Suggested by Me: In addition to the topics proposed by GPT-4, I will be introducing several subjects of my own choosing, reflecting my unique perspective and interests. These topics will encompass a diverse range of areas, further enriching the conversations in this series. By incorporating my ideas, I can ensure that the conversations are not only informative but also engaging and relevant to my audience. The topics I bring forth will allow me to delve deeper into the world of AI while maintaining the essence of my website's thematic focus. The collaboration between AI-generated ideas and my own input will result in a stimulating and well-rounded discussion. Through this partnership, I can demonstrate the true potential of AI in fostering meaningful conversations and driving human creativity. As I traverse these topics with ChatGPT, I hope to provide my readers with a captivating exploration of the ever-expanding world of artificial intelligence, igniting curiosity and fostering a deeper understanding of the role AI can play in shaping our future. In the upcoming articles, I will share detailed conversations I have with ChatGPT, showcasing both its capabilities and limitations. Through these dialogues, I hope to spark thought-provoking discussions around the themes presented and provide valuable insights into the world of AI. I invite you to join me on this fascinating journey as we explore the frontiers of artificial intelligence and ponder the potential it holds for shaping the future of human endeavor. Stay tuned for the next installment of the "ChatGPT and Me" series! Me: Make this a much larger article. Include anything else that might be relevant such as history of AI, Large Language Models, OpenAI, and ChatGPT. GPT-4: Title: ChatGPT and Me: Exploring the Boundaries of AI Conversations Introduction: Welcome to the first article in our "ChatGPT and Me" series, where I embark on an intellectual adventure, delving into the capabilities and limitations of OpenAI's GPT-4 language model. As I engage in stimulating conversations spanning a wide array of topics, I aim to uncover the improvements in GPT-4 over its predecessor, GPT-3, and scrutinize the nuances of human-AI interactions. Throughout this series, I will contemplate the implications of artificial intelligence on our rapidly evolving world and discuss its potential to shape the future of human knowledge and creativity. The History of AI: To better understand the significance of ChatGPT, it's essential to explore the history of artificial intelligence. The field of AI has its roots in the 1950s, when the concept of "thinking machines" was first introduced. Early AI research focused on rule-based systems and logic programming, eventually giving way to more sophisticated techniques such as machine learning and deep learning. Over the decades, AI development has been marked by cycles of optimism and skepticism, as researchers have made significant advances followed by periods of stagnation. Large Language Models and OpenAI: In recent years, the development of large-scale language models has revolutionized the field of AI. These models, such as OpenAI's GPT series, employ deep learning techniques to process and generate human-like text. OpenAI, founded in 2015, has been at the forefront of this revolution, with the release of GPT-2 in 2019 and GPT-3 in 2020, both of which garnered widespread attention for their unprecedented language capabilities. With the release of GPT-4, OpenAI has pushed the boundaries of natural language processing even further. ChatGPT: ChatGPT is a powerful AI language model developed by OpenAI, based on the GPT-4 architecture. It can engage in human-like conversations, generating contextually relevant and coherent responses. The potential applications for ChatGPT are vast, ranging from virtual assistants and customer support to content generation and creative writing. However, the ethical implications of such advanced AI technology must also be considered, as the potential for misuse and the impact on jobs and society at large cannot be ignored. Topics Generated by GPT-4:
These topics were specifically selected to reflect the breadth of subjects covered on my "In Deep Thought" website and to provide a comprehensive understanding of ChatGPT and its implications. By exploring these topics, I can dive deep into the world of AI, its capabilities, and its potential consequences for various fields. Topics Suggested by Me: In addition to the topics proposed by GPT-4, I will be introducing several subjects of my own choosing, reflecting my unique perspective and interests. These topics will encompass a diverse range of areas, further enriching the conversations in this series. By incorporating my ideas, I can ensure that the conversations are not only informative but also engaging and relevant to my audience. The topics I bring forth will allow me to delve deeper into the world of AI while maintaining the essence of my website's thematic focus. The collaboration between AI-generated ideas and my own input will result in a stimulating and well-rounded discussion. Through this partnership, I can demonstrate the true potential of AI in fostering meaningful conversations and Me: continue GPT-4: driving human creativity. As I traverse these topics with ChatGPT, I hope to provide my readers with a captivating exploration of the ever-expanding world of artificial intelligence, igniting curiosity and fostering a deeper understanding of the role AI can play in shaping our future. Ethical Considerations and the Future of AI: As we delve into the world of AI and the capabilities of ChatGPT, it is crucial to address the ethical considerations surrounding this technology. The potential for misuse, such as generating misleading or harmful content, must be carefully examined. Additionally, the impact of AI on employment, privacy, and society at large is a topic that requires thoughtful discussion. As we explore the potential benefits of AI, we must also consider the steps necessary to mitigate potential risks and ensure that AI serves as a force for good. In the upcoming articles, I will share detailed conversations I have with ChatGPT, showcasing both its capabilities and limitations. Through these dialogues, I hope to spark thought-provoking discussions around the themes presented and provide valuable insights into the world of AI. I invite you to join me on this fascinating journey as we explore the frontiers of artificial intelligence and ponder the potential it holds for shaping the future of human endeavor. Stay tuned for the next installment of the "ChatGPT and Me" series! Me: The following is an article you and I have been working on. Please make it better and expand where you see fit. Title: ChatGPT and Me: Exploring the Boundaries of AI Conversations The following is what OpenAI's ChatGPT-4 came up with to introduce this series given my prompts and with some cajoling. I am not all that good of a writer, so for the most part I will either post the final product as the article or splice together one the best I can. As this series continues, if any given article in the series itself is not the conversation, I will provide a link to the conversation that resulted in the article. In some cases there will be a conclusion as well with my thoughts on the conversation, the resulting article, and other random stuff. This is an exploratory series of using ChatGPT for both the fun of it and the technical use of it. It is not necessarily about the veracity of the output ChatGPT gives. ...prior article as output by GPT-4... GPT-4: Title: ChatGPT and Me: Unraveling the World of AI Conversations The following article is the result of a creative partnership between OpenAI's ChatGPT-4 and me, as we explore the boundaries of AI-generated conversations. As a non-professional writer, I will rely on the model's capabilities to create engaging content while I share my thoughts on various topics. Throughout this series, I will provide links to the conversations that inspired each article and occasionally add my personal reflections. This exploratory series delves into the intriguing and technical aspects of ChatGPT, focusing on understanding its potential rather than solely on the accuracy of its output. Introduction: Welcome to the inaugural article in our "ChatGPT and Me" series, where I embark on an intellectual journey to investigate the capabilities and limitations of OpenAI's GPT-4 language model. Through stimulating conversations on a wide array of subjects, I will explore the advancements in GPT-4 compared to its predecessor, GPT-3, and analyze the intricacies of human-AI interactions. Along the way, I will contemplate the impact of artificial intelligence on our rapidly evolving world and discuss its potential to shape the future of human knowledge and creativity. The Evolution of AI: To better appreciate ChatGPT's significance, we must delve into the history of artificial intelligence. The field of AI has its origins in the 1950s when the concept of "thinking machines" first emerged. Early AI research focused on rule-based systems and logic programming, eventually leading to more sophisticated techniques such as machine learning and deep learning. Over the decades, AI development has experienced cycles of optimism and skepticism, with researchers making significant advances followed by periods of stagnation. Large Language Models and OpenAI: The development of large-scale language models in recent years has revolutionized the field of AI. These models, including OpenAI's GPT series, use deep learning techniques to process and generate human-like text. OpenAI, established in 2015, has led this revolution, releasing GPT-2 in 2019 and GPT-3 in 2020, both receiving widespread attention for their unparalleled language capabilities. With GPT-4, OpenAI has further pushed the boundaries of natural language processing. ChatGPT: OpenAI's ChatGPT, based on the GPT-4 architecture, is a powerful AI language model capable of engaging in human-like conversations. It generates contextually relevant and coherent responses, with potential applications ranging from virtual assistants and customer support to content generation and creative writing. However, the ethical implications of such advanced AI technology must also be considered, as the potential for misuse and its impact on jobs and society at large cannot be overlooked. Topics Generated by GPT-4:
These topics, carefully chosen to represent the breadth of subjects covered on my "In Deep Thought" website, aim to provide a comprehensive understanding of ChatGPT and its implications. By exploring these themes, we will dive deep into the world of AI, its capabilities, and its potential consequences for various fields. Topics Suggested by Me: In addition to GPT-4's proposed topics, I will introduce several subjects reflecting my unique perspective and interests. These topics will encompass a diverse range of areas, further enriching the conversations in this series. By incorporating my ideas, we ensure the discussions are not only informative but Me: continue GPT-4: also engaging and relevant to my audience. The topics I present will allow us to delve deeper into the world of AI while maintaining the essence of my website's thematic focus. The collaboration between AI-generated ideas and my input will result in a stimulating and well-rounded discussion. Through this partnership, we can demonstrate the true potential of AI in fostering meaningful conversations and driving human creativity. As we traverse these topics with ChatGPT, our goal is to provide readers with a captivating exploration of the ever-expanding world of artificial intelligence, igniting curiosity and fostering a deeper understanding of the role AI can play in shaping our future. Ethical Considerations and the Future of AI: As we examine the world of AI and ChatGPT's capabilities, it is crucial to address the ethical considerations surrounding this technology. We must carefully examine the potential for misuse, such as generating misleading or harmful content, and thoughtfully discuss the impact of AI on employment, privacy, and society at large. As we explore the potential benefits of AI, we must also consider the necessary steps to mitigate potential risks and ensure AI serves as a force for good. In upcoming articles, I will share detailed conversations I have with ChatGPT, showcasing its capabilities and limitations. Through these dialogues, we hope to spark thought-provoking discussions around the themes presented and provide valuable insights into the world of AI. I invite you to join me on this fascinating journey as we explore the frontiers of artificial intelligence and ponder the potential it holds for shaping the future of human endeavor. Stay tuned for the next installment of the "ChatGPT and Me" series! posted by dharh 1:28 AM Apr 24th, 2023
Exploring the Boundaries of AI Conversations
The following article is the result of a creative partnership between OpenAI's ChatGPT-4 and me, as we explore the boundaries of AI-generated conversations. As a non-professional writer, I will rely on the model's capabilities to create engaging content while I share my thoughts on various topics. Throughout this series, I will provide links to the conversations that inspired each article and occasionally add my personal reflections. This exploratory series delves into the intriguing and technical aspects of ChatGPT, focusing on understanding its potential rather than solely on the accuracy of its output. Introduction: Welcome to the inaugural article in our "ChatGPT and Me" series, where I embark on an intellectual journey to investigate the capabilities and limitations of OpenAI's GPT-4 language model. Through stimulating conversations on a wide array of subjects, I will explore the advancements in GPT-4 compared to its predecessor, GPT-3, and analyze the intricacies of human-AI interactions. Along the way, I will contemplate the impact of artificial intelligence on our rapidly evolving world and discuss its potential to shape the future of human knowledge and creativity. The Evolution of AI: To better appreciate ChatGPT's significance, we must delve into the history of artificial intelligence. The field of AI has its origins in the 1950s when the concept of "thinking machines" first emerged. Early AI research focused on rule-based systems and logic programming, eventually leading to more sophisticated techniques such as machine learning and deep learning. Over the decades, AI development has experienced cycles of optimism and skepticism, with researchers making significant advances followed by periods of stagnation. Large Language Models and OpenAI: The development of large-scale language models in recent years has revolutionized the field of AI. These models, including OpenAI's GPT series, use deep learning techniques to process and generate human-like text. OpenAI, established in 2015, has led this revolution, releasing GPT-2 in 2019 and GPT-3 in 2020, both receiving widespread attention for their unparalleled language capabilities. With GPT-4, OpenAI has further pushed the boundaries of natural language processing. ChatGPT: OpenAI's ChatGPT, based on the GPT-4 architecture, is a powerful AI language model capable of engaging in human-like conversations. It generates contextually relevant and coherent responses, with potential applications ranging from virtual assistants and customer support to content generation and creative writing. However, the ethical implications of such advanced AI technology must also be considered, as the potential for misuse and its impact on jobs and society at large cannot be overlooked. Topics Generated by GPT-4:
These topics, carefully chosen to represent the breadth of subjects covered on my "In Deep Thought" website, aim to provide a comprehensive understanding of ChatGPT and its implications. By exploring these themes, we will dive deep into the world of AI, its capabilities, and its potential consequences for various fields. Topics Suggested by Me: In addition to GPT-4's proposed topics, I will introduce several subjects reflecting my unique perspective and interests. These topics will encompass a diverse range of areas, further enriching the conversations in this series. By incorporating my ideas, we ensure the discussions are not only informative but also engaging and relevant to my audience. The topics I present will allow us to delve deeper into the world of AI while maintaining the essence of my website's thematic focus. The collaboration between AI-generated ideas and my input will result in a stimulating and well-rounded discussion. Through this partnership, we can demonstrate the true potential of AI in fostering meaningful conversations and driving human creativity. As we traverse these topics with ChatGPT, our goal is to provide readers with a captivating exploration of the ever-expanding world of artificial intelligence, igniting curiosity and fostering a deeper understanding of the role AI can play in shaping our future. Ethical Considerations and the Future of AI: As we examine the world of AI and ChatGPT's capabilities, it is crucial to address the ethical considerations surrounding this technology. We must carefully examine the potential for misuse, such as generating misleading or harmful content, and thoughtfully discuss the impact of AI on employment, privacy, and society at large. As we explore the potential benefits of AI, we must also consider the necessary steps to mitigate potential risks and ensure AI serves as a force for good. In upcoming articles, I will share detailed conversations I have with ChatGPT, showcasing its capabilities and limitations. Through these dialogues, we hope to spark thought-provoking discussions around the themes presented and provide valuable insights into the world of AI. I invite you to join me on this fascinating journey as we explore the frontiers of artificial intelligence and ponder the potential it holds for shaping the future of human endeavor. Stay tuned for the next installment of the "ChatGPT and Me" series! posted by dharh 1:16 AM Apr 24th, 2023
As I have mentioned before I have been working, albeit slowly, on finally finishing the conversion of the site from ColdFusion to C#.NET. By and by recently chatGPT has roared onto the internet with a bang, might even say a BING, and although code assist AI, with github, has been in a sort of beta state for the last several months (or even year?) I have thought that a way to revitalize my enthusiasm for working on this site is the start to mess around with it.
As such I have decided to do multiple things. One is to try to use chatGPT while I work in the C# code for this site and document the journey in so doing. Two, since programming and philosophy are some of the main focuses of the site, I will create a series called ChatGPT And Me (initially called Chatting With ChatGPT) where I will post various chats that I have with chatGPT on a wide range of subjects. Three, I will revive the Learning a new Programming Language series with chatGPT at the helm with critiques from me. I'm hoping this will be fun and interesting for both me and any audience there might be. posted by dharh 12:45 AM Feb 22nd, 2023
12. Extract uppercase words from a file, extract unique words
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
namespace lrn2CSharp12
{
class Program
{
static void Main( string[ ] args )
{
string file = "";
string line = "";
string[ ] words;
List<string> upperWords = new List<string>( );
List<string> uniqueWords = new List<string>( );
Console.WriteLine( "Input name of a file to read and count words." );
Console.Write( ":" );
try
{
file = Console.ReadLine( );
FileStream fs = new FileStream( file, FileMode.Open, FileAccess.Read );
StreamReader sr = new StreamReader( fs );
while ( !sr.EndOfStream )
{
line = sr.ReadLine( );
words = null;
if ( line.Length != 0 )
words = line.Split( ' ' );
if ( words != null )
{
foreach ( string w in words )
{
if ( char.IsUpper( w[ 0 ] ) )
upperWords.Add( w );
if ( !uniqueWords.Contains( w ) )
uniqueWords.Add( w );
}
}
}
sr.Close( );
fs.Close( );
}
catch
{
Console.WriteLine( "WTF?!?" );
}
Console.WriteLine( "Upper Words:" );
foreach ( string s in upperWords )
{
Console.Write( s );
Console.WriteLine( );
}
Console.WriteLine( );
Console.WriteLine( "Unique Words:" );
foreach ( string s in uniqueWords )
{
Console.Write( s );
Console.WriteLine( );
}
Console.WriteLine( );
Console.WriteLine( "Press esc to exit." );
while ( !keyPressHandler( Console.ReadKey( true ) ) )
{
Thread.Sleep( 250 );
/* no op */
}
}
private static Boolean keyPressHandler( ConsoleKeyInfo input )
{
if ( input.Key == ConsoleKey.Escape )
return true;
return false;
}
}
}
posted by dharh 1:08 AM May 30th, 2011
11. Input is HTML table, Remove all tags and put data in a comma/tab separated file.
Part of this was an exercise in looking up what others have already done. using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using System.Text.RegularExpressions;
using System.Threading;
namespace lrn2CSharp11
{
class Program
{
static void Main( string[ ] args )
{
string file = "";
string html = "";
DataSet ds = null;
StringBuilder csv = new StringBuilder( );
Console.WriteLine( "Input name of a file with an HTML table in the current directory to convert to csv." );
Console.Write( ":" );
try
{
file = Console.ReadLine( );
FileStream fs = new FileStream( file, FileMode.Open, FileAccess.Read );
StreamReader sr = new StreamReader( fs );
html = sr.ReadToEnd( );
sr.Close( );
StreamWriter sw = new StreamWriter( fs.Name + ".csv" );
ds = ConvertHTMLTablesToDataSet( html );
if ( ds != null )
{
foreach ( DataTable dtc in ds.Tables )
{
int iColCount = dtc.Columns.Count;
for ( int i = 0; i < iColCount; i++ )
{
sw.Write( dtc.Columns[ i ] );
if ( i < iColCount - 1 )
{
sw.Write( "," );
}
}
sw.WriteLine( );
foreach ( DataRow dr in dtc.Rows )
{
for ( int i = 0; i < iColCount; i++ )
{
if ( !Convert.IsDBNull( dr[ i ] ) )
{
sw.Write( dr[ i ].ToString( ) );
}
if ( i < iColCount - 1 )
{
sw.Write( "," );
}
}
sw.WriteLine( );
}
sw.WriteLine( );
}
}
sw.Close( );
fs.Close( );
}
catch
{
Console.WriteLine( "WTF?!?" );
}
Console.WriteLine( "Press esc to exit." );
while ( !keyPressHandler( Console.ReadKey( true ) ) )
{
Thread.Sleep( 250 );
/* no op */
}
}
private static Boolean keyPressHandler( ConsoleKeyInfo input )
{
if ( input.Key == ConsoleKey.Escape )
return true;
return false;
}
private static DataSet ConvertHTMLTablesToDataSet( string HTML )
{
DataTable dt;
DataSet ds = new DataSet( );
dt = new DataTable( );
string TableExpression = "<table[^>]*>(.*?)</table>";
string HeaderExpression = "<th[^>]*>(.*?)</th>";
string RowExpression = "<tr[^>]*>(.*?)</tr>";
string ColumnExpression = "<td[^>]*>(.*?)</td>";
bool HeadersExist = false;
int iCurrentColumn = 0;
int iCurrentRow = 0;
MatchCollection Tables = Regex.Matches(
HTML,
TableExpression,
RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase
);
foreach ( Match Table in Tables )
{
iCurrentRow = 0;
HeadersExist = false;
dt = new DataTable( );
if ( Table.Value.Contains( "<th" ) )
{
HeadersExist = true;
MatchCollection Headers = Regex.Matches(
Table.Value,
HeaderExpression,
RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase
);
foreach ( Match Header in Headers )
{
dt.Columns.Add( Header.Groups[ 1 ].ToString( ) );
}
}
else
{
int columns = Regex.Matches(
Regex.Matches(
Regex.Matches(
Table.Value,
TableExpression,
RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase
)[ 0 ].ToString( ),
RowExpression,
RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase
)[ 0 ].ToString( ),
ColumnExpression,
RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase
).Count;
for ( int iColumns = 1; iColumns <= columns; iColumns++ )
{
dt.Columns.Add( "Column " + System.Convert.ToString( iColumns ) );
}
}
MatchCollection Rows = Regex.Matches(
Table.Value,
RowExpression,
RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase
);
foreach ( Match Row in Rows )
{
if ( !( ( iCurrentRow == 0 ) & HeadersExist ) )
{
DataRow dr = dt.NewRow( );
iCurrentColumn = 0;
MatchCollection Columns = Regex.Matches(
Row.Value,
ColumnExpression,
RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase
);
foreach ( Match Column in Columns )
{
dr[ iCurrentColumn ] = Column.Groups[ 1 ].ToString( );
iCurrentColumn++;
}
dt.Rows.Add( dr );
}
iCurrentRow++;
}
ds.Tables.Add( dt );
}
return ds;
}
}
}
posted by dharh 11:42 PM May 29th, 2011
Hopefully this new year will see some more activity from me. That's my new years resolution for IDT.
As a sort of quick plan for what I want to do this year:
Let's see how it all goes. posted by dharh 10:37 AM Jan 3rd, 2011
« Previous 1 2 3 4 5 Next »
|
AI airships america batteries blogs books browser C# c++ chatGPT computers conversation copyright covid cpp cr-48 CSharp dharh disaster DIY DRM economy energy environment FCC gaming google government history HTML humor idt internet interview japan java javascript linkjack linux lrn2program MLP moving music nature nefeedeater neThing neTodo networking news opensource philosophy podcasts poverty programming projects python reading religion science sick simple software space sparce tagging technology twitter unbirthday video wiki
|