Package: zensols.nlp
Zensols Natural Language ParsingThis framework wraps thespaCyframework and creates light weight features in
a classhierarchythat reflects the structure of natural language.  The
motivation is to generate features from the parsed text in an object oriented
fashion that is fast and easy to pickle.See thefull documentation.Paper onarXiv.Other features include:Parse and normalizea stream of tokens as stop words, punctuation
filters, up/down casing, porter stemming andothers.Detached featuresthat are safe and easy to pickle to disk.Configuration drive parsing and token normalization usingconfiguration
factories.Pretty print functionality for easy natural language feature selection.A comprehensivescoring moduleincluding following scoring methods:RougeBleuSemEval-2013 Task 9.1Levenshtein distanceExact matchDocumentationFramework documentationNatural Language ParsingList Token Normalizers and MappersObtaining / InstallingThe easiest way to install the command line program is via thepipinstaller.  Since the package needs at least one spaCy module, the second
command downloads the smallest model.pip3install--use-deprecated=legacy-resolverzensols.nlp
python-mspacydownloaden_core_web_smBinaries are also available onpypi.UsageA parser using the default configuration can be obtained by:fromzensols.nlpimportFeatureDocumentParserparser:FeatureDocumentParser=FeatureDocumentParser.default_instance()doc=parser('Obama was the 44th president of the United States.')fortokindoc.tokens:print(tok.norm,tok.pos_,tok.tag_)print(doc.entities)>>>ObamaPROPNNNPwasAUXVBDtheDETDT45thADJJJpresidentNOUNNNofADPINtheUnitedStatesDETDT.PUNCT.(<Obama>,<45th>,<theUnitedStates>)However, minimal effort is needed to configure the parser using aresource library:fromioimportStringIOfromzensols.configimportImportIniConfig,ImportConfigFactoryfromzensols.nlpimportFeatureDocument,FeatureDocumentParserCONFIG="""# import the `zensols.nlp` library[import]config_file = resource(zensols.nlp): resources/obj.conf# override the parse to keep only the norm, ent[doc_parser]token_feature_ids = set: ent_, tag_"""if(__name__=='__main__'):fac=ImportConfigFactory(ImportIniConfig(StringIO(CONFIG)))doc_parser:FeatureDocumentParser=fac('doc_parser')sent='He was George Washington and first president of the United States.'doc:FeatureDocument=doc_parser(sent)fortokindoc.tokens:tok.write()This uses aresource libraryto source in the configuration from this package
so minimal configuration is necessary.  More advanced configurationexamplesare also available.See thefeature documentsfor more information.ScoringCertain scores in thescoring moduleneed additional Python packages.  These
are installed with:pipinstall-Rsrc/python/requirements-score.txtAttributionThis project, or example code, uses:spaCyfor natural language parsingmsgpackandsmart-openfor Python disk serializationnltkfor theporter stemmerfunctionalityCitationIf you use this project in your research please use the following BibTeX entry:@inproceedings{landes-etal-2023-deepzensols,title="{D}eep{Z}ensols: A Deep Learning Natural Language Processing Framework for Experimentation and Reproducibility",author="Landes, Paul  andDi Eugenio, Barbara  andCaragea, Cornelia",editor="Tan, Liling  andMilajevs, Dmitrijs  andChauhan, Geeticka  andGwinnup, Jeremy  andRippeth, Elijah",booktitle="Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023)",month=dec,year="2023",address="Singapore, Singapore",publisher="Empirical Methods in Natural Language Processing",url="https://aclanthology.org/2023.nlposs-1.16",pages="141--146"}ChangelogAn extensive changelog is availablehere.CommunityPlease star this repository and let me know how and where you use this API.
Contributions as pull requests, feedback and any input is welcome.LicenseMIT LicenseCopyright (c) 2020 - 2023 Paul Landes