{"id":26933204,"url":"https://github.com/xiaohan2012/capitalization-restoration-train","last_synced_at":"2025-04-02T09:17:52.744Z","repository":{"id":140895472,"uuid":"41725152","full_name":"xiaohan2012/capitalization-restoration-train","owner":"xiaohan2012","description":"Training code for the capitalization restorer","archived":false,"fork":false,"pushed_at":"2015-09-07T19:22:21.000Z","size":20712,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-14T18:06:57.056Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/xiaohan2012.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}},"created_at":"2015-09-01T07:58:01.000Z","updated_at":"2020-03-07T01:25:21.000Z","dependencies_parsed_at":"2023-03-13T06:45:43.035Z","dependency_job_id":null,"html_url":"https://github.com/xiaohan2012/capitalization-restoration-train","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/xiaohan2012%2Fcapitalization-restoration-train","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaohan2012%2Fcapitalization-restoration-train/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaohan2012%2Fcapitalization-restoration-train/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaohan2012%2Fcapitalization-restoration-train/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiaohan2012","download_url":"https://codeload.github.com/xiaohan2012/capitalization-restoration-train/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246785477,"owners_count":20833498,"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":[],"created_at":"2025-04-02T09:17:52.151Z","updated_at":"2025-04-02T09:17:52.737Z","avatar_url":"https://github.com/xiaohan2012.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Producing new data set for CRF classifier\n\nUse the working script: `new_data_pipeline.sh`. Basically, it does the above.\n\nOr do the following step by step by hand(not recommended)\n\n1. `python print_filenames_and_titles.py`: get the file paths and news titles that accords to our requirement(non-monocase title and non-empty article body)\n2. `python copy_puls_file_to_local.py`: copy the files somewhere writable\u0026accessible\n3. `python extract_doc_ids.py`: save the ids of documents to be used\n4. `puls-core-process-document.sh`: using PULS to preprocess the documents. This will generate the `.auxil` files\n5. `process_and_save_capitalized_headlines.py`: save the malformed headlines somewhere\n6. `make_data_puls.py`: extract the features for CRF classifier to use\n7. `train_puls_model.sh`: train the model\n\n## Producing new data set for rule-based classifier\n\nThe process is divided into two parts: one part is shared with the data creation process for CRF classifier(step 1 to 5).\n\nThe other is outputing the labels in separate files for the rule-based classifier to use.\n\nRun `make_rule_based_corpus.sh`\n\n\n## Evaluation\n### CRF classifier evaluation\n\nRefer to the comments in `train_puls_model.sh` and comment/uncomment certain lines to do that.\n\nItermediate performance statitics(as they will be processed later) will be saved in target paths as specified in that script.\n\n\n### Rule-based classifier evaluation\n\nDo the following:\n\n- Change the variables in `puls-rule-based-parallel.sh` if you'd like to\n- Run `puls-rule-based-parallel.sh` to use the IE rule-based capitalization recovery tool to process the evaluation data\n- Go to the directory specified by `$result_dir` variable in the `puls-rule-based-parallel.sh` and concatenate all the result files (starting with `id_`) into a whole result file\n- Run `python evaluate.py` to print the result matrix, where rows are the statistics for each label and columns are `number of match`, `number of predictions y model` and `number of lables in reality`\n\n\n**short-cut**:\n\nAs the data preparation is done, if you want to evaluate rule-based classifier, just run the above plus the final post score processing.\n\n### Post processing\n\nBoth evaluation scripts print out itermediate result(like number of correct predictions support) for the final scores. You need to run replace the data in `calc_cv_result.py` according to the comment in the script and run it.\n\n\n\n## Trainable document Id path\n\nDocuments are filtered by whether their title is trainable(correctly-capitalized) and whether they contain non-empty body, the list of document ids is saved under `data/tmp/2015-08-18/filtered_trainable_doc_ids.txt`\n\n\n\n## Printing error example\n\nFor CRF classiier, `pred_err.py` will print out the error examples as well as confusion matrix\n\n    \u003e # Example: python pred_err.py ${model_path} ${test_sentence_path} ${test_sentence_feature_path}\n\t\u003e DATA_ROOT=/cs/taatto/home/hxiao/capitalization-recovery\n    \u003e python pred_err.py --model ${DATA_ROOT}/result/feature/cap/1+2+3+4+5+6/model --sent_path ${DATA_ROOT}/corpus/news_title_cap/30000/test.txt --crfsuite_path ${DATA_ROOT}/result/feature/cap/1+2+3+4+5+6/test.crfsuite.txt\n\nFor rule-based classifier, `evaluate.py` will do the same role. Note, you need to set `print_errors=True` when  calling `eval_rule_based` in the `evaluate.py` script.\n\n\n## TODO\n- Add more features to handle mixed-case words, for example: TSX-Venture, or split the word by the hyphen\n- In capitalized titles(more information is preserved), some words are already all-uppercase/mixed-cased. Dictionary feature does not take into account mixed case words.\n- Spelling/morphology, funds = fund + s\n- POS tag for capitalized words seems to tend to be NNP. Maybe lowercase the sentence and capitalize it?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaohan2012%2Fcapitalization-restoration-train","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaohan2012%2Fcapitalization-restoration-train","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaohan2012%2Fcapitalization-restoration-train/lists"}