Package: nlpcube
News[05 August 2021]- We are releasing version 3.0 of NLPCube and models and introducingFLAVOURS. This is a major update, but we did our best to maintain the same API, so previous implementation will not crash. The supported language list is smaller, but you can open an issue for unsupported languages, and we will do our best to add them. Other options include fixing the pip package version 1.0.8pip install nlpcube==0.1.0.8.[15 April 2019]- We are releasing version 1.1 models - check allsupported languages below. Both 1.0 and 1.1 models are trained on the sameUD2.2 corpus; however, models 1.1 do not use vector embeddings, thus reducing disk space and time required to use them. Some languages actually have a slightly increased accuracy, some a bit decreased. By default, NLP Cube will use the latest (at this time) 1.1 models.To use the older 1.0 models just specify this version in theloadcall:cube.load("en", 1.0)(enfor English, or any other language code). This will download (if not already downloaded) and usethisspecific model version. Same goes for any language/version you want to use.If you already have NLP Cube installed andwant to use the newer 1.1 models, type eithercube.load("en", 1.1)orcube.load("en", "latest")to auto-download them. After this, callingcube.load("en")without version number will automatically use the latest ones from your disk.NLP-CubeNLP-Cube is an opensource Natural Language Processing Framework with support for languages which are included in theUD Treebanks(list of all available languages below). Use NLP-Cube if you need:Sentence segmentationTokenizationPOS Tagging (both language independent (UPOSes) and language dependent (XPOSes and ATTRs))LemmatizationDependency parsingExample input:"This is a test.", output is:1       This    this    PRON    DT      Number=Sing|PronType=Dem        4       nsubj   _
2       is      be      AUX     VBZ     Mood=Ind|Number=Sing|Person=3|Tense=Pres|VerbForm=Fin   4       cop     _
3       a       a       DET     DT      Definite=Ind|PronType=Art       4       det     _
4       test    test    NOUN    NN      Number=Sing     0       root    SpaceAfter=No
5       .       .       PUNCT   .       _       4       punct   SpaceAfter=NoIf you just want to run it, here's how to set it up and use NLP-Cube in a few lines:Quick Start Tutorial.Foradvanced users that want to create and train their own models, please see the Advanced Tutorials inexamples/, starting with how tolocally install NLP-Cube.Simple (PIP) installation / update versionInstall (or update) NLP-Cube with:pip3install-UnlpcubeAPI UsageTo use NLP-Cube *programmatically(in Python), followthis tutorialThe summary would be:fromcube.apiimportCube# import the Cube objectcube=Cube(verbose=True)# initialize itcube.load("en",device='cpu')# select the desired language (it will auto-download the model on first run)text="This is the text I want segmented, tokenized, lemmatized and annotated with POS and dependencies."document=cube(text)# call with your own text (string) to obtain the annotationsThedocumentobject now contains the annotated text, one sentence at a time. To print the third words's POS (in the first sentence), just run:print(document.sentences[0][2].upos) # [0] is the first sentence and [2] is the third wordEach token object has the following attributes:index,word,lemma,upos,xpos,attrs,head,label,deps,space_after. For detailed info about each attribute please see the standard CoNLL format.FlavoursPrevious versions on NLP-Cube were trained on individual treebanks. This means that the same language was supported by
multiple models at the same time. For instance, you could parse English (en) text withen_ewt,en_esl,en_lines,
etc. The current version of NLPCube combines all flavours of a treebank under the same umbrella, by jointly optimizing
a conditioned model. You only need to load the base language, for exampleenand then select which flavour to apply
at runtime:from cube.api import Cube       # import the Cube object
cube=Cube(verbose=True)         # initialize it
cube.load("en", device='cpu')   # select the desired language (it will auto-download the model on first run)
text="This is the text I want segmented, tokenized, lemmatized and annotated with POS and dependencies."


# Parse using the default flavour (in this case EWT)
document=cube(text)            # call with your own text (string) to obtain the annotations
# or you can specify a flavour
document=cube(text, flavour='en_lines')Webserver UsageThe current version dropped supported, since most people preferred to implement their one NLPCube as a service.CiteIf you use NLP-Cube in your research we would be grateful if you would cite the following paper:NLP-Cube: End-to-End Raw Text Processing With Neural Networks, Boroș, Tiberiu and Dumitrescu, Stefan Daniel and Burtica, Ruxandra, Proceedings of the CoNLL 2018 Shared Task: Multilingual Parsing from Raw Text to Universal Dependencies, Association for Computational Linguistics. p. 171--179. October 2018or, in bibtex format:@InProceedings{boro-dumitrescu-burtica:2018:K18-2,
  author    = {Boroș, Tiberiu  and  Dumitrescu, Stefan Daniel  and  Burtica, Ruxandra},
  title     = {{NLP}-Cube: End-to-End Raw Text Processing With Neural Networks},
  booktitle = {Proceedings of the {CoNLL} 2018 Shared Task: Multilingual Parsing from Raw Text to Universal Dependencies},
  month     = {October},
  year      = {2018},
  address   = {Brussels, Belgium},
  publisher = {Association for Computational Linguistics},
  pages     = {171--179},
  abstract  = {We introduce NLP-Cube: an end-to-end Natural Language Processing framework, evaluated in CoNLL's "Multilingual Parsing from Raw Text to Universal Dependencies 2018" Shared Task. It performs sentence splitting, tokenization, compound word expansion, lemmatization, tagging and parsing. Based entirely on recurrent neural networks, written in Python, this ready-to-use open source system is freely available on GitHub. For each task we describe and discuss its specific network architecture, closing with an overview on the results obtained in the competition.},
  url       = {http://www.aclweb.org/anthology/K18-2017}
}Languages and performanceFor comparison, the performance of 3.0 models is reported on the 2.2 UD corpus, but distributed models are obtained from UD 2.7.Results are reported against the test files for each language (available in the UD 2.2 corpus) using the 2018 conll eval script. Please see more info about whateach metric represents here.Notes:version 1.1 of the models no longer need the large external vector embedding files. This makes loading the 1.1 models faster and less RAM-intensive.all reported results here are end-2-end. (e.g. we test the tagging accuracy on our own segmented text, as this is the real use-case; CoNLL results are mostly reported on "gold" - or pre-segmented text, leading to higher accuracy for the tagger/parser/etc.)LanguageModelTokenSentenceUPOSXPOSAllTagsLemmasUASLASChinesezh-1.093.0399.1088.2288.1586.9192.7473.4369.52zh-1.192.3499.1086.7586.6685.3592.0571.0067.04zh.3.095.8887.3691.6783.5482.7485.8879.1570.08Englishen-1.099.2572.895.3494.8392.4895.6284.781.93en-1.199.270.9494.493.9391.0495.1883.380.32en-3.098.9575.0096.0195.7193.7596.0687.0684.61Frenchfr-1.099.6894.292.6195.4690.7993.0884.9680.91fr-1.199.6795.3192.5195.4590.893.083.8880.16fr-3.099.7193.9297.3399.5696.6190.7989.8187.24Germande-1.099.781.1991.3894.2680.3775.879.674.35de-1.199.7781.9990.4793.8279.7975.4679.373.87de-3.099.7786.2594.7097.0085.0282.7387.0882.69Hungarianhu-1.099.894.1894.5299.886.2291.0781.5775.95hu-1.199.8897.7793.1199.8886.7991.1877.8970.94hu-3.099.7591.6496.4399.7589.8991.3186.3481.29Italianit-1.099.8998.1486.8686.6784.9787.0378.374.59it-1.199.9299.0786.5886.484.5386.7576.3872.35it-3.099.9298.1398.2698.1597.3497.7694.0792.66Romanian (RO-RRT)ro-1.099.7495.5697.4296.5995.4996.9190.3885.23ro-1.199.7195.4296.9696.3294.9896.5790.1485.06ro-3.099.8095.6497.6797.1196.7697.5592.0687.67Spanishes-1.099.9898.3298.098.096.6298.0590.5388.27es-1.199.9898.4098.0198.0096.697.9990.5188.16es-3.099.9697.1796.8899.9194.8898.1792.1189.86