{"id":32747711,"url":"https://github.com/alwaysvivek/next-word-prediction","last_synced_at":"2026-04-12T02:35:18.223Z","repository":{"id":322133838,"uuid":"1088330856","full_name":"alwaysvivek/next-word-prediction","owner":"alwaysvivek","description":"🔮 Predicts the next word in a text sequence using either an N-gram statistical model or an LSTM-based neural network.","archived":false,"fork":false,"pushed_at":"2025-11-02T19:05:22.000Z","size":334,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-02T20:24:00.295Z","etag":null,"topics":["argparse","laplace-smoothing","machine-learning","neural-network","ngrams","nlp","nltk","numpy","python3","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alwaysvivek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-02T19:01:30.000Z","updated_at":"2025-11-02T19:07:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/alwaysvivek/next-word-prediction","commit_stats":null,"previous_names":["alwaysvivek/next-word-prediction"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/alwaysvivek/next-word-prediction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysvivek%2Fnext-word-prediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysvivek%2Fnext-word-prediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysvivek%2Fnext-word-prediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysvivek%2Fnext-word-prediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alwaysvivek","download_url":"https://codeload.github.com/alwaysvivek/next-word-prediction/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysvivek%2Fnext-word-prediction/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31702580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T21:17:31.016Z","status":"online","status_checked_at":"2026-04-12T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["argparse","laplace-smoothing","machine-learning","neural-network","ngrams","nlp","nltk","numpy","python3","tensorflow"],"created_at":"2025-11-03T20:00:59.830Z","updated_at":"2026-04-12T02:35:18.216Z","avatar_url":"https://github.com/alwaysvivek.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📚 Next Word Prediction\n\nThis project 🔮 predicts the next word in a sequence based on a given text corpus. It implements two different approaches:\n\n1.  **N-gram Model:** A statistical language model that predicts the next word based on the preceding N-1 words.\n2.  **Neural Network Model:** A deep learning model (specifically, an LSTM network) that learns to predict the next word from the text data.\n\n## ⚙️ Requirements\n\n*   Python 3.x\n*   nltk\n*   tensorflow\n*   numpy\n\nTo install the dependencies, run:\n\n```bash\npip install nltk tensorflow numpy\n```\n\n## 🚀 Usage\n\n1.  Clone the repository.\n2.  Run the `next_word_prediction.py` script.\n3.  You will be prompted to enter the following:\n    *   The value of `n` for the N-gram model (e.g., 3 for trigrams).\n    *   The seed text for prediction.\n    *   The model type (`ngram` or `nn`).\n\n```bash\npython next_word_prediction.py --corpus \u003ccorpus_file.txt\u003e\n```\n\n## 📊 N-gram Model\n\nThe N-gram model uses Laplace smoothing to handle unseen N-grams. The smoothing factor (alpha) is set to 1 by default. The vocabulary size is determined from the training corpus.\n\n## 🧠 Neural Network Model\n\nThe neural network model is a simple LSTM network with an embedding layer, an LSTM layer, and a dense output layer. The model is trained on the input text data. It's crucial to have a large enough corpus for effective training.\n\n## 💾 Training Data\n\nThe project uses `Pride and Prejudice.txt` as the default training data. You can replace this file with your own text file.\n\n## 📝 Notes\n\n*   The neural network model may require significant training time depending on the size of the corpus.\n*   The performance of the models depends on the quality and size of the training data.\n*   The neural network implementation is a basic example and can be further improved by tuning hyperparameters, adding more layers, or using different architectures.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwaysvivek%2Fnext-word-prediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falwaysvivek%2Fnext-word-prediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwaysvivek%2Fnext-word-prediction/lists"}