{"id":27247661,"url":"https://github.com/aoof/factoid-project","last_synced_at":"2025-04-10T22:58:27.036Z","repository":{"id":260040429,"uuid":"880076043","full_name":"Aoof/factoid-project","owner":"Aoof","description":"FactoidProject is a console application designed to analyze and answer questions based on the data provided by the user. The application processes the input data, identifies the type of question, and attempts to find the best possible answer from the data.","archived":false,"fork":false,"pushed_at":"2024-12-02T17:05:07.000Z","size":4500,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T22:58:21.752Z","etag":null,"topics":["college-project","csharp","factoid"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aoof.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-29T04:10:28.000Z","updated_at":"2024-12-02T16:57:16.000Z","dependencies_parsed_at":"2024-10-29T07:26:35.421Z","dependency_job_id":"5e4c699c-e206-4e9f-8ab8-14aa2632f99b","html_url":"https://github.com/Aoof/factoid-project","commit_stats":null,"previous_names":["aoof/factoid-project"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aoof%2Ffactoid-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aoof%2Ffactoid-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aoof%2Ffactoid-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aoof%2Ffactoid-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aoof","download_url":"https://codeload.github.com/Aoof/factoid-project/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312151,"owners_count":21082638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["college-project","csharp","factoid"],"created_at":"2025-04-10T22:58:26.233Z","updated_at":"2025-04-10T22:58:27.016Z","avatar_url":"https://github.com/Aoof.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FactoidProject\n\n![FactoidProject Demonstration](./factoid-project-demo-spedup.gif)\n\n## Binary Release\n\n- Download the binary release from the [releases page](https://github.com/Aoof/factoid-project/releases/latest).\n\n## Installation\n\n1. **Install the .NET SDK:**\n   - Download and install the [.NET SDK](https://dotnet.microsoft.com/download) for your platform.\n\n1. **Clone the repository:**\n   ```sh\n   git clone https://github.com/Aoof/factoid-project.git\n   cd factoid-project\n   ```\n\n2. **Build the project:**\n   ```sh\n   dotnet build\n   ```\n\n3. **Run the project:**\n   ```sh\n   dotnet run\n   ```\n\n## Overview\n\nFactoidProject is a console application designed to analyze and answer questions based on the data provided by the user. The application processes the input data, identifies the type of question, and attempts to find the best possible answer from the data.\n\n## Main Components\n\u003e \n\u003e Altered version of pseudocodes to help explain it concisely are provided for the main components of the application, including the main method, question processing, data retrieval, answer extraction, similarity calculation, and user interface components.\n\u003e \n\u003e **Message to the viewer**: *This project was initially created as a study project to demonstrate the implementation of a factoid question-answering system using C#. I was using GitHub to store and control the project and its changes with my team members, and decided to have fun with it and create a relatively decent repository structure for it, since I had the time and the motivation to do so.*\n\n### 1. Main Method\nThe entry point of the application. It sets up the console, prompts the user for data, and enters a loop to process user questions until the user decides to exit.\n```csharp\nvoid Main(string[] args)\n```\n**Pseudocode:**\n```\nSet console title and clear console\nShow welcome message\nPrompt user for data\nIf data is provided, store it; otherwise, use placeholder data\nEnter main loop:\n    Get user input\n    If input is \"exit\", break loop\n    If input is \"guide\", show guide\n    If input is \"data\", show data\n    Otherwise, process the question\n    Prompt user to continue\n    Reset bubbles\n```\n\n### 2. ProcessQuestion Method\nAnalyzes the user's question, determines the type of question, retrieves relevant data, and calculates the similarity between the question and the data to find the best possible answer. It also displays the question, answer, and similarity percentage in a styled format.\n```csharp\nvoid ProcessQuestion(string input)\n```\n**Pseudocode:**\n```\nDetermine question type\nRetrieve data sentences\nInitialize variables for max similarity and best sentence\nFor each sentence:\n    Remove stop words\n    Calculate similarity with input\n    Sum similarities\n    Get answers based on question type\n    If similarity is highest and answers are valid, update max similarity and best sentence\nCalculate lexical match percentage\nGet best answers from best sentence\nIf no valid answers, set default answer\nShow question, answer, and similarity percentage in styled format\n```\n\n### 3. GetAnswers Method\nDetermines the type of answer to extract based on the question type (e.g., person, place, date, number) and retrieves the relevant answers from the given sentence. It uses helper methods to extract specific types of information.\n```csharp\nstring[] GetAnswers(string sentence, string questionType)\n```\n**Pseudocode:**\n```\nSplit sentence into words and trim whitespace\nJoin words back into a sentence\nSwitch based on question type:\n    If \"PERSON\", call GetPeople\n    If \"PLACE\", call GetPlaces\n    If \"DATE\", call GetDates\n    If \"NUMBER\", call GetNumbers\n    Otherwise, return default answer\nReturn answers\n```\n\n### 4. RetrieveData Method\nProcesses the input data by splitting it into sentences and cleaning up unnecessary characters. This method ensures that the data is in a suitable format for analysis.\n```csharp\nstring[] RetrieveData(string input)\n```\n**Pseudocode:**\n```\nReplace newlines with spaces in data\nReplace \"Inc.\" with \"Inc\"\nSplit data into sentences based on punctuation\nTrim and clean up each sentence\nReturn sentences\n```\n\n### 5. RemoveStopWords Method\nRemoves common stop words from a given string to improve the accuracy of the similarity calculation. This method helps in focusing on the meaningful words in the sentences.\n```csharp\nstring RemoveStopWords(string str)\n```\n**Pseudocode:**\n```\nDefine list of stop words\nSplit input string into words\nFor each word:\n    If word is a stop word, remove it\nJoin remaining words into a string\nReturn cleaned string\n```\n\n### 6. GetPeople, GetPlaces, GetDates, GetNumbers Methods\nEach method extracts specific types of information (people, places, dates, numbers) from a given sentence. These methods are used by the `GetAnswers` method to find relevant answers based on the question type.\n```csharp\nstring[] GetPeople(string sentence)\nstring[] GetPlaces(string sentence)\nstring[] GetDates(string sentence)\nstring[] GetNumbers(string sentence)\n```\n**Pseudocode for GetPeople:**\n```\nSplit sentence into words\nInitialize list for people\nFor each word:\n    If word starts with an uppercase letter, add to people list\nReturn list of people\n```\n\n**Pseudocode for GetPlaces:**\n```\nSplit sentence into words\nInitialize list for places\nFor each word:\n    If word is uppercase, add to places list\nReturn list of places\n```\n\n**Pseudocode for GetDates:**\n```\nSplit sentence into words\nInitialize list for dates\nFor each word:\n    If word contains date format or is a valid year, add to dates list\nReturn list of dates\n```\n\n**Pseudocode for GetNumbers:**\n```\nSplit sentence into words\nInitialize list for numbers\nFor each word:\n    If word contains number format, add to numbers list\nReturn list of numbers\n```\n\n### 7. GetSimilarity Method\nCalculates the similarity between the user's question and a given sentence from the data. This method helps in identifying the most relevant sentence that matches the user's question.\n```csharp\ndouble GetSimilarity(string input, string sentence)\n```\n**Pseudocode:**\n```\nSplit input and sentence into words\nInitialize similarity counter\nFor each word in input:\n    For each word in sentence:\n        If words match, increment similarity counter\nCalculate similarity as ratio of matches to minimum length of input and sentence\nReturn similarity\n```\n\n### 8. GetQuestionType Method\nIdentifies the type of question based on specific keywords (e.g., who, where, when, how many, how much). This method helps in determining the type of answer to extract.\n```csharp\nstring GetQuestionType(string input)\n```\n**Pseudocode:**\n```\nConvert input to lowercase\nDefine list of keywords and corresponding question types\nFor each keyword:\n    If input contains keyword, return corresponding question type\nReturn \"UNKNOWN\" if no match found\n```\n\n### 9. ShowData Method\nDisplays the current data and allows the user to enter new data. This method provides an interface for the user to manage the data being analyzed.\n```csharp\nvoid ShowData()\n```\n**Pseudocode:**\n```\nClear console\nShow data information in styled format\nPrompt user to enter new data\nIf new data is provided, update data\n```\n\n### 10. ShowGuide Method\nDisplays a guide explaining how to use the application and the special commands available. This method helps users understand the functionality and usage of the application.\n```csharp\nvoid ShowGuide()\n```\n**Pseudocode:**\n```\nClear console\nShow program guide in styled format\nShow special commands in styled format\n```\n\n### 11. ShowBubble Method\nDisplays messages in a styled \"bubble\" format on the console. This method enhances the user interface by presenting information in a visually appealing way.\n```csharp\nvoid ShowBubble(string text, ConsoleColor color = ConsoleColor.DarkGreen)\n```\n**Pseudocode:**\n```\nStore message in bubbles array\nCalculate box dimensions based on console width\nSet console color\nDraw top border of bubble\nSplit text into lines\nFor each line:\n    Draw line within bubble\nDraw bottom border of bubble\nReset console color\n```\n\n### 12. CommandString Method\nFormats command descriptions for display in the guide and input prompt. This method helps in presenting the commands in a consistent and readable format.\n```csharp\nstring CommandString(string command, string description)\n```\n**Pseudocode:**\n```\nFormat command and description into a single string\nReturn formatted string\n```\n\n### 13. GetInput Method\nDisplays the main input prompt to the user, including the title, student names, special commands, and captures the user's input. This method provides an interface for the user to interact with the application.\n```csharp\nstring GetInput(string prompt = \"Enter your question: \")\n```\n**Pseudocode:**\n```\nClear console\nDefine sections and commands\nSet console color\nCalculate box dimensions based on console width\nDraw top border of input box\nDraw title, student names, and special commands within box\nDraw prompt within box\nDraw bottom border of input box\nReset console color\nSet cursor position for input\nRead user input\nReturn user input\n```\n\n## Special Commands\n\n- `exit` - Exit the program\n- `guide` - Show the guide of the program\n- `data` - Show the data you have entered\n\n## Example Usage\n\n1. **Enter Data:**\n   ```\n   Enter your data:\n   The history of programming languages spans from documentation of early mechanical computers to modern tools for software development. Early programming languages were highly specialized, relying on mathematical notation and similarly obscure syntax. Throughout the 20th century, research in compiler theory led to the creation of high-level programming languages, which use a more accessible syntax to communicate instructions. The first high-level programming language was created by Konrad Zuse in 1943. The first high-level language to have an associated compiler was created by Corrado Böhm in 1951. Konrad Zuse was born on 1910/06/22, in GERMANY, and was a notable civil engineer, pioneering computer scientist, inventor, and businessman.\n   ```\n\n2. **Ask Questions:**\n   ```\n   Enter your question: Who created the first high-level programming language?\n   ```\n\n3. **View Answer:**\n   ```\n   Konrad Zuse \n   ```\n\n4. **Ask More Questions:**\n   ```\n   Enter your question: When was Konrad Zuse born?\n   ```\n\n5. **View Answer:**\n   ```\n   1910/06/22\n   ```\n\n\n## Conclusion\nThis is a small study project that demonstrates the implementation of a factoid question-answering system using C#. The application processes user questions, retrieves relevant data, calculates similarity, and extracts answers based on the question type. The pseudocode provides a high-level overview of the main components and methods used in the application. The user interface components enhance the user experience by presenting information in a visually appealing and structured format. The special commands allow users to manage data, view guides, and exit the program easily. Overall, the application showcases the basic functionality of a factoid question-answering system and serves as a foundation for further development and enhancements.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faoof%2Ffactoid-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faoof%2Ffactoid-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faoof%2Ffactoid-project/lists"}