{"id":18305790,"url":"https://github.com/yaricom/english-article-correction","last_synced_at":"2025-04-05T16:32:47.964Z","repository":{"id":94042484,"uuid":"84460551","full_name":"yaricom/english-article-correction","owner":"yaricom","description":"The experiment with applying NLP to correction of definite/indefinite articles in English text corpus","archived":false,"fork":false,"pushed_at":"2017-03-28T12:48:14.000Z","size":18803,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T06:51:20.851Z","etag":null,"topics":["data-analysis","glove-vectors","nlp","nlp-machine-learning","numpy","pandas","scikit-learn","umbc-webbase-corpus"],"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/yaricom.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}},"created_at":"2017-03-09T15:55:30.000Z","updated_at":"2020-11-22T13:49:34.000Z","dependencies_parsed_at":"2023-05-03T12:00:32.727Z","dependency_job_id":null,"html_url":"https://github.com/yaricom/english-article-correction","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaricom%2Fenglish-article-correction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaricom%2Fenglish-article-correction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaricom%2Fenglish-article-correction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaricom%2Fenglish-article-correction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaricom","download_url":"https://codeload.github.com/yaricom/english-article-correction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247366929,"owners_count":20927625,"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":["data-analysis","glove-vectors","nlp","nlp-machine-learning","numpy","pandas","scikit-learn","umbc-webbase-corpus"],"created_at":"2024-11-05T15:35:43.657Z","updated_at":"2025-04-05T16:32:47.958Z","avatar_url":"https://github.com/yaricom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"The repository contains the source code for experiment with applying NLP to correction of English definite/indefinite articles in text corpus\n\n## Setting up working environment\n\n### Dependencies\n\nThe source code in this directory is written in Python 3 and number of dependencies on\ncommon Python libraries for ML and NLP:\n\n1. [Numpy](https://docs.scipy.org/doc/numpy/index.html) - the Base N-dimensional array package\n2. [Pandas](http://pandas.pydata.org/pandas-docs/stable/index.html) - the data analysis toolkit for Python\n3. [scikit-learn](http://scikit-learn.org/stable/) - the collection of tools for data mining and data analysis\n\nAll dependencies can be installed manually or as part of distributive by installing `Anaconda` data science platform.\nFor `Anaconda` installation instructions visit [Anaconda web site](https://www.continuum.io/downloads). \nIn order to use source code present in this directory install `Anaconda3` which includes `Python3`.\n\n## The data corpus\n\nThe data corpora in this experiment was generated using UMBC WebBase corpus.\nUMBC WebBase corpus by Lushan Han, UMBC Ebiquity Lab (http://ebiquity.umbc.edu/) is licensed under a \nCreative Commons Attribution 3.0 Unported License (http://creativecommons.org/licenses/by/3.0/deed.en_US). \nBased on a work at http://ebiq.org/r/351.\n\nThe data corpora comprise of following files:\n\n1. sentences: sentence_train.txt, sentence_test.txt\n2. corrections: corrections_train.txt, corrections_test.txt\n3. constituency parse trees: parse_train.txt, parse_test.txt\n4. dependency parse trees: dependencies_train.txt, dependencies_test.txt\n5. part of speech tags: pos_tags_train.txt, pos_tags_test.txt\n6. GloVe vectors indexes for list of vectors in glove_vectors.txt file: glove_train.txt, glove_test.txt\n\nBefore running experiments unpack data corpus archive file `data.zip` into `data` directory\n\n## Source code structure\n\nThe source code consists of series of `Python3` scripts encapsulating specific functionality:\n\n* [config.py](src/config.py) - holds common configuration parameters (file and directories names, global constants, etc)\n* [data_set.py](src/data_set.py) - the data sets generator to transform raw corpora into Numpy arrays with features and labels\n* [data_set_test.py](src/data_set_test.py) - the unit tests for `data_set.py` script\n* [tree_dict.py](src/tree_dict.py) - the parser and manipulation utilities for `constituency parse trees`\n* [tree_dict_test.py](src/tree_dict_test.py) - the unit tests for `tree_dict.py` script\n* [utils.py](src/utils.py) - the common utilities, such as: JSON parsing, data corpora sanity checks, etc\n* [predictor.py](src/predictor.py) - the predictive models runner. Encapsulates common functionality which can be applied\nto different predictors.\n* [random_forest_model.py](src/random_forest_model.py) - the predictive model based on `sklearn.ensemble.RandomForestClassifier`\n* [evaluate.py](src/evaluate.py) - the results evaluation script where the target metric is not accuracy but recall level at a specified false positive rate level.\n\n## Running experiments\n\nBefore running experiments with training a model that detects and corrects an incorrect usage of \nthe English article (“a”, “an” or “the”) we need to process raw data corpora files.\n\nTo generate data set files execute from the terminal in the root directory following command:\n```\n$ create_data_set.sh\n```\n\nThe generated data sets comprise features and labels per specific text corpora. The total of sixteen features considered as important.\nSome of the features represented the words and POS tags found at specific locations adjacent to the determiner (only English articles: a, an, the); \nothers represented the nouns, and verbs that preceded or followed the determiner.\nTable 1 shows a subset of the feature list.\n\n| Index | Feature | Description |\n| ----- | ------- | ----------- |\n| 0     | PrW     | The preceding word's Glove index|\n| 1     | PrW POS | The preceding word's POS tag |\n| 2     | DTa     | The Glove index of determiner (only English articles: a, an, the) |\n| 3     | FlW     | The following word's Glove index |\n| 4     | FlW POS | The following word's POS tag |\n| 5     | FlW2    | The second following word's Glove index |\n| 6     | FlW2 POS | The second following word's POS tag |\n| 7     | FlNNs (i \u003e 0) | The Glove index of following single/plural noun (where DT is not at the start of sentence) |\n| 8     | FlNNs (i \u003e 0) POS | The following single/plural noun's POS tag |\n| 9     | PrW2 | The second preceding word's Glove index |\n| 10    | PrW2 POS | The second preceding word's POS tag |\n| 11    | PrW3 (VB, VBD) | The Glove index of third preceding verb (VB, VBD) if present |\n| 12    | PrW3 (VB, VBD) POS | The POS tag of third preceding verb (VB, VBD) if present |\n| 13    | Vowel [0, 1] | The flag to indicate if following word starts with specific vowel |\n| 14    | FlW (VB,VBD,VBG,VBN,VBP,VBZ) | The Glove index of third following verb (VB,VBD,VBG,VBN,VBP,VBZ) if present |\n| 15    | FlW (VB,VBD,VBG,VBN,VBP,VBZ) POS | The POS tag of third following verb (VB,VBD,VBG,VBN,VBP,VBZ) if present |\n\n**Table 1** The features list description\n\nTo run prediction against *validation corpora* with subsequent evaluation against ground truth \nlabels execute from the terminal in the root directory following command:\n```\n$ run_validate.sh\n```\n\nTo run prediction against *test corpora* with default parameters execute from the terminal \nin the root directory following command:\n```\n$ generate_results.sh\n```\n\nThe predicted results will be saved in `out` directory as `submission_test.txt` file.\n\n## Conclusions\n\nAs result of conducted experiments and analysis, several main findings can be released:\n1. The provided data corpora have a small number of samples which excludes building of advanced predictive models\nbased on neural network methods.\n2. The best predictive performance was achieved with ensemble classifiers based on decision trees architecture.\n3. Among tried decision tree algorithms the best prediction score was achieved with \n[Random Forest Classifier](http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html)\n4. It was found that the optimal number of estimators for the classifier is 1500. Other parameters were selected as by default.\n\nThe results for validation corpora by running `evaluate.py` script:\n```\nFP counts: {'the': 1519, 'an': 77,  'a': 435} \nFN counts: {'the': 1054, 'an': 112, 'a': 597}\nTP counts: {'the': 5114, 'an': 97,  'a': 1142}\nTN counts: {'the': 7093, 'an': 286, 'a': 2084}\n\u003e\u003e\u003e target score = 40.28 % (measured at 0.02 false positive rate level)\n\u003e\u003e\u003e accuracy (just for info) = 80.70 %\n```\n\n## Authors\n\nThis source code maintained and managed by Iaroslav Omelianenko\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaricom%2Fenglish-article-correction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaricom%2Fenglish-article-correction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaricom%2Fenglish-article-correction/lists"}