Package: ucrel-api
UCREL Python APIPython API to theUCREL Tool Chain.Installpip install ucrel_api%%capture# If you are running this in Google Colab:!pipinstallucrel_apiExamplesConnecting to the APIYou can connect to the publicUCREL Tool Chainlike so:fromucrel_api.apiimportUCREL_APIapi=UCREL_API('a.moore@lancaster.ac.uk','http://ucrel-api.lancaster.ac.uk')As shown it requires an email address and server address, of which the server address in this case is the address of the public UCREL Tool Chain. The email address is only used to detect misuse of the public UCREL Tool Chain. Please be kind to this public server, UCREL provides it free of charge and is not intended for extremely large numbers of repeated submission from the same site.USASOnce we have an API insance we can use it to call theUSAS tagger:text_to_process=('Hope you have a nice day. ''Works with SGML entities e.g. 5 > 4.''Also with MWE like New York.')ucrel_doc=api.usas(text_to_process)forindex,sentenceinenumerate(ucrel_doc.sentences):print(f'Sentence{index}')fortokeninsentence:print(token)ifindex==0orindex==1:print('\n')Sentence 0
UCREL Token: Hope	Lemma: hope	POS tag: VV0	USAS tag: X2.6+
UCREL Token: you	Lemma: you	POS tag: PPY	USAS tag: Z8mf
UCREL Token: have	Lemma: have	POS tag: VH0	USAS tag: A9+
UCREL Token: a	Lemma: a	POS tag: AT1	USAS tag: Z5
UCREL Token: nice	Lemma: nice	POS tag: JJ	USAS tag: O4.2+
UCREL Token: day	Lemma: day	POS tag: NNT1	USAS tag: T1.3
UCREL Token: .	Lemma: PUNC	POS tag: .


Sentence 1
UCREL Token: Works	Lemma: works	POS tag: NN	USAS tag: I4/H1c
UCREL Token: with	Lemma: with	POS tag: IW	USAS tag: Z5
UCREL Token: SGML	Lemma: sgml	POS tag: NP1	USAS tag: Z99
UCREL Token: entities	Lemma: entity	POS tag: NN2	USAS tag: O2
UCREL Token: e.g.	Lemma: e.g.	POS tag: REX	USAS tag: A4.1
UCREL Token: 5	Lemma: 5	POS tag: MC	USAS tag: N1
UCREL Token: >	Lemma: >	POS tag: FO	USAS tag: Z99
UCREL Token: 4	Lemma: 4	POS tag: MC	USAS tag: N1
UCREL Token: .	Lemma: PUNC	POS tag: .


Sentence 2
UCREL Token: Also	Lemma: also	POS tag: RR	USAS tag: N5++
UCREL Token: with	Lemma: with	POS tag: IW	USAS tag: Z5
UCREL Token: MWE	Lemma: mwe	POS tag: NP1	USAS tag: Z99
UCREL Token: like	Lemma: like	POS tag: II	USAS tag: Z5
UCREL Token: New	Lemma: new	POS tag: NP1	USAS tag: Z2	MWE tag: 2.2.1
UCREL Token: York	Lemma: york	POS tag: NP1	USAS tag: Z2	MWE tag: 2.2.2
UCREL Token: .	Lemma: PUNC	POS tag: .The return of theUCREL_API.usasapi call is aUCREL_Docinstance, theUCREL_Docinstance is made up ofUCREL_Tokens. The USAS tagger provides both token level attributes and sentence segmentation as shown above.DevelopmentIf you would like to develop on this library. Clone the repository and then install the regular requirements and the development requirements using:pipinstall-e.[dev]The-eis an editable flagmeaning that if you change anything in the library locally Python will keep track on those changes.Package is created with nbdevNoteas it is created with nbdev the code and documentation is generated from the notebooks that are within the./module_notebooks folder.Noteneed to run the following once:nbdev_install_git_hooks:"This will set up git hooks which will remove metadata from your notebooks when you commit, greatly reducing the chance you have a conflict."The main workflow is the following:Edit the notebook(s) you want within./module_notebooks folder.The README is generated from the./module_notebooks/index.ipynb file.Runnbdev_build_libto convert the notebook(s) into a Python module, which in this case will go into the./ucrel_api folder.Noteif you created a function in one python module and want to use it in another module then you will need to runnbdev_build_libfirst, as that python module code needs to be transfered from the./module_notebooks folder.into the./ucrel_api folder.Create the documentation usingnbdev_build_docs.Optionallyif you created tests run them usingmake test. When you do add tests in the notebooks you will need to import the function from the module and not rely on the function already expressed in the notebook, this is to ensure that code coverage is calculated correctly.Optionallyif you would like to see the documentation locally see thesub-section below.Git add the relevant notebook(s), python module code, and documentation.Local documentationThe documentation can be ran locally via a docker container. The easiest way to run this container is through the make command:makedocker_docs_serveNOTEThis documentation does not update automatically, so it requires re-running this make command each time you want to see an updated version of the documentation.PYPI Package releaseTo release an updated version of the package:Change the version number in./settings.iniBuild the library usingnbdev_build_libThen make the package and upload it to PYPI usingmake releaseAcknowledgementThe work has been funded by theUCREL research centre at Lancaster University.