NlphoseBuilder : A tool to create NLP pipelines via drag and drop
Tags: nlp, machinelearning, javascript, datascience
Published: 2021-07-17 19:05:23

> ✨Checkout the live [demo here] (https://ashishware.com/static/nlphose.html)

Recently  I completed work on a tool called [nlphoseGUIBuilder](https://github.com/code2k13/nlphoseGUI) that allows creation of complex NLP pipelines visually, without writing a single line of code ! It uses [Blockly](https://developers.google.com/blockly/) to enable creation of NLP pipelines using drag and drop. 

Currently following operations are supported:
* Sentiment Analysis (AFINN)
* NER (Spacy)
* Language Identification (FastText)
* Chunking (NLTK)
* Sentiment Analysis (Transformers)
* Question Answering (Transformers)
* Zero shot Classification (Transformers)


The tool generates a nlphose command that can be executed in a docker container to run the pipeline. These pipelines can process streaming text like tweets or static data like files. They can be executed just like normal shell command using [nlphose](https://github.com/code2k13/nlphose).  Let me show you what I mean !

Below is pipeline that searches Twitter for tweets containing 'netflix' and performs named entity recognition on it.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qiru18lsctkolq63i2j0.png)

It generates a nlphose command which looks like this

```shell
twint -s netflix |\ 
./twint2json.py |\ 
./entity  |\ 
./senti 
```
When the above pipeline is run using  [nlphose](https://github.com/code2k13/nlphose), you can expect to see stream of JSON output similar to the one shown below:

```shell
....
{
  "id": "6a5fe972-e2e6-11eb-9efa-42b45ace4426",
  "text": "Wickham were returned, and to lament over his absence from the Netherfield ball. He joined them on their entering the town, and attended them to their aunt’s where his regret and vexation, and the concern of everybody, was well talked over. To Elizabeth, however, he voluntarily acknowledged that the necessity of his absence _had_ been self-imposed.",
  "afinn_score": -1.0,
  "entities": [
    {
      "label": "PERSON",
      "entity": "Wickham"
    },
    {
      "label": "ORG",
      "entity": "Netherfield"
    },
    {
      "label": "PERSON",
      "entity": "Elizabeth"
    }
  ]
}
...
```

Lets try out something more, the below pipeline searches for tweets containing the word 'rainfall' and then finds the location where it rained using 'extractive question answering'. It also filters out answers with lower scores.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z4hdnfxqeodrk7ax2x92.png)

Here is the nlphose command it generates:
```shell
twint -s rainfall |\ 
./twint2json.py |\ 
./xformer.py --pipeline question-answering --param 'where did it rain' |\ 
jq 'if (.xfrmr_question_answering.score) > 0.80 then . else empty end'
```

It is also possible to create a pipeline that processes multiple files from a folder :
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lgj0aoiqlfnqj704xgu3.png)


The above pipeline generates this command:
```shell
./files2json.py -n 3  data/*.txt |\ 
./xformer.py --pipeline question-answering --param 'who gave the speech ?' |\ 
jq 'if (.xfrmr_question_answering.score) > 0.80 then . else empty end'
```

Play with the tool here: https://ashishware.com/static/nlphose.html

Here is the link to the projects git repository: [https://github.com/code2k13/nlphoseGUI](https://github.com/code2k13/nlphoseGUI)

Here is a YouTube link of the tool in action:
{% youtube X-BmStLY-DY %}

Don't forget to checkout the repository of the companion project nlphose: https://github.com/code2k13/nlphose