Package: ner-annotator
Named Entity Recognition AnnotatorThis repository contains a NER utility to annotate text, given some entities.Dark GUILight GUIInstallationTo install this GUI you need to make sure that you havePython 3on your system.
Then,cdinto the project's root and run:pipinstall.This will install thener_annotatorpackage and its required dependencies (mainlyPyQt5).UsageTo run this utility, execute the following command:ner_annotator<input>-o<output>-e<entities>Here,<input>is the path to the input text file, which should contain your training text lines, separated by newlines;<output>is the path to where you would like to save the.jsonoutput file (if not given, it defaults to the same directory as the input file);<entities>is the list of entities you would like to annotate.For example, I could run the program like this:ner_annotator'~/Desktop/train.txt'-e'BirthDate''Name'You can also optionally pass an existing NER model to the annotator, so as to identify entities using that model (button between previous and next line controls in the GUI) and eventually modify/add/remove them. For example:ner_annotator'~/Desktop/train.txt'-e'BirthDate''Name'-m'~/Desktop/NER'Currently, onlySpaCymodels are supported, but you can contribute to the project and add compatibility with other NER models, by checking themodel.pyfile inside thener_annotatorpackage.The great thing about this package is that it is able to automagically identify the correct library for the given model (i.e. you don't have to specify that your model should be loaded withSpaCyor any other NLP library).Config fileIn order to have a faster annotation experience, you can save your model entities names to reuse them the next time you are going to need this tool.To do that, you need to create a.jsonfile (seeassets/json/config.json), with a schema like the following:{"models":[{"name":"example-1","entities":["entity-1-1","entity-1-2","entity-1-3"]},{"name":"example-2","entities":["entity-2-1","entity-2-2"]}]}To use the entities of the modelexample-1, for example, you can run:python3annotator.py'~/Desktop/train.txt'-c'~/Desktop/config.json'-n'example-1'Here,~/Desktop/config.jsonis the path to the.jsonfile mentioned above.This bash command will be the equivalent in this example:python3annotator.py'~/Desktop/train.txt'-e'entity-1-1''entity-1-2''entity-1-3'OutputThe utility software will output a.jsonfile with the following schema:[{"content":"text","entities":[[0,1,"entity"]]}]You can convert this output into the specific format required by your NER model by passing the-poption to thener_annotatortool. In this way, on your output folder you will also find apicklefile (with the same name as the given.jsonoutput file, but with no extension), which can then be used to load entities in another program with the requested NLP library. To load the saved pickle file, you can do something along these lines:importpicklepickle.load(open("~/Desktop/output",'rb'))In this example,ner_annotatorwas either called with-o ~/Desktop/output.jsonor without the-ooption but with-i ~/Desktop/train.txtor similar.Currently, onlySpaCymodels conversion is provided.DistributionThis package is available onPyPy, so you can also install it by simply running:pipinstallner-annotatorYou can also install extra packages, likeSpaCy:pipinstallner-annotator[spacy]Personal note: In order to upload a new version of the package to PyPy, just executescripts/deploy.sh, insert__token__as Twine username and the saved API token as Twine password.Thanks toGUI icons are provided byIcons8