# openNlp don't return valid result in pdf

**URL:** <https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566>\
**Category:** Elasticsearch\
**Created:** [March 12, 2018, 2:34pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566 "2018-03-12T14:34:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 12, 2018, 2:34pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/1 "2018-03-12T14:34:56Z")

</div>

Hello, i've succeded, recently thanks to this site to link opennlp ,to my pdf.  
However the result wasn't as good as i expected.

This the pdf :

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/6/a6543ae415f177aaf905014abeee438a72f68017.png)

and this what i get :

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/1/91055a865a27c1bc293e58ea2fa28f64dbdab8bd.png)

what is wrong with plugin  
is there something i need to fix before using it ??

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 12, 2018, 2:47pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/2 "2018-03-12T14:47:34Z")

</div>

Hard to read images. Would be better to paste text only specifically when it's not a UI problem.

Anyway, what looks wrong here?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 12, 2018, 3:16pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/4 "2018-03-12T15:16:23Z")

</div>

Not sure I understand the "problem". Looks like your document has entities for persons, locations, dates.

So what is wrong? What do you expect?

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 13, 2018, 1:43pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/6 "2018-03-13T13:43:15Z")

</div>

i 've many name in my pdf, althought openNlp didn't return them  
also i' ve many adresses ,it didn't return it all

what i have get right are the dates .  
need it a configuration ??

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 13, 2018, 2:21pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/7 "2018-03-13T14:21:06Z")

</div>

Can you reproduce it with just nlp plugin and provide just a text as the input ?

If you can may be worth opening an issue in the nlp project ?

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 13, 2018, 2:28pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/8 "2018-03-13T14:28:05Z")

</div>

```
  PUT _ingest/pipeline/opennlp-pipeline
    {
      "description": "A pipeline to do named entity extraction",
      "processors": [
      {
      "attachment" : {
       "field" : "mycontentfield"
       }
      },
    {
      "opennlp" : {
       "field" : "attachment.content"
     }
    }
 ]
}

  PUT /indice14/type/1?pipeline=opennlp-pipeline
  {
     "mycontentfield":"base64of the pdf" 
  }

```

it was the response i get here for a previous question.

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 13, 2018, 2:33pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/9 "2018-03-13T14:33:42Z")

</div>

where can i post an issue in Nlp project here or where ?  
i can't find a categorie named nlp project here !!!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 13, 2018, 5:06pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/10 "2018-03-13T17:06:45Z")

</div>

I said: without the attachment plugin. Could you reproduce and share your script?

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 13, 2018, 5:40pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/11 "2018-03-13T17:40:00Z")

</div>

No with just nlp plugin i can't .  
Actually i have asked [here](https://discuss.elastic.co/t/elasticsearch-ingest-opennlp-pdf/122921) and the owner of the plugin "Alexander Reelsen" responded that i need to use attachment plugin first.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 13, 2018, 6:32pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/12 "2018-03-13T18:32:05Z")

</div>

No. He told you that if you want to extract text from a PDF document you need to use ingest-attachment.  
If you want to send the text to NLP then you need to use the NLP plugin.

What I'm asking for is to use only NLP and send to it just some text.  
And reproduce the issue you are seeing.

What you can do is also to use the `_simulate` ingest endpoint with the verbose option to see what is happening at each step. [https://www.elastic.co/guide/en/elasticsearch/reference/6.2/simulate-pipeline-api.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/simulate-pipeline-api.html)

And share it here and also **a full reproduction script** if you need help.

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 14, 2018, 1:54pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/13 "2018-03-14T13:54:36Z")

</div>

yes , today i've put as you told me just a text in openNlp plugin and the result was the same !

this what i wrote in _dev tools_ :

```
PUT /index20/type/1?pipeline=opennlp-pipeline
{
 "my_field":"Ahmed HADDAD Développement et\nAvenue de l’UMA\n\n\nConception en\n2035 
  Charguia 2\n\njava/JEE\n\nTél :25932722\n\nhaddadahmed1994@gmail.com\n23 
   ans\nFORMATION\n2017-2018 3éme année Génie Informatique\n2014-2015Diplôme Ingénieur 
   premier cycle\n2011-2012 Diplôme BAC Science\nLangues\n : Anglais-Français et de 
   L’italien\n\nEXPERIENCES\n\nAôut 2017 : Stage en Advance Web djerba—réalisation d’un tchat en 
  AJAX et JQuery\n\n\nJuilliet 2016 : Stage d’Intiation en Advance Web djerba-un Blog communautaire     
  php et Mysql\n\n\nLOISIRS\nJ’aime la Consultation des News Lettre des Communauté informatique 
dans le web,\nJouer les Jeux videos Steam online , un peu d’echec."
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 14, 2018, 2:13pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/14 "2018-03-14T14:13:11Z")

</div>

Using `simulate` is easier.  
Anyway, what is the output of

```auto
GET index20/type/1

```

?

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 14, 2018, 2:21pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/15 "2018-03-14T14:21:37Z")

</div>

this is the response

```
 {
  "_index": "index20",
  "_type": "type",
  "_id": "1",
  "_version": 1,
   "found": true,
  "_source": {
   "my_field": """
 Ahmed HADDAD Développement et
Avenue de l’UMA

Conception en
2035 Charguia 2

java/JEE

Tél :25932722

haddadahmed1994@gmail.com
23 ans
FORMATION
2017-2018 3éme année Génie Informatique
2014-2015Diplôme Ingénieur premier cycle
2011-2012 Diplôme BAC Science
Langues
: Anglais-Français et de L’italien

EXPERIENCES

Aôut 2017 : Stage en Advance Web djerba—réalisation d’un tchat en AJAX et JQuery

Juilliet 2016 : Stage d’Intiation en Advance Web djerba-un Blog communautaire php et Mysql

 LOISIRS
J’aime la Consultation des News Lettre des Communauté informatique dans le web,
Jouer les Jeux videos Steam online , un peu d’echec.
""",
"entities": {
  "persons": [
    "Mysql LOISIRS J",
    "Avenue"
  ],
  "dates": [
        "2011 - 2012",
        "1994",
         "2016",
        "2014 - 2015",
       "2035"
      ],
     "locations": [
    "Avenue de l"
      ]
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 14, 2018, 2:54pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/16 "2018-03-14T14:54:14Z")

</div>

What do you expect?

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 14, 2018, 4:00pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/17 "2018-03-14T16:00:16Z")

</div>

I expect :  
In person : Ahmed HADDAD  
In dates: the same but without "-"  
in locations: Avenue de l’UMA,2035 Charguia 2,djerba

also

1. i see that the owner of the plugin have created "WHATEVER like person and dates and locations"
2. what are the regex or the method he used to parse the file and extract these informations ? and could we change them ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 14, 2018, 4:34pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/18 "2018-03-14T16:34:56Z")

</div>

I'm not familiar with this plugin but I wonder if it's a problem about the language used.

Here your text is in french. May be you are using the default models which are in english (if I understand correctly this part of the doc):

```auto
ingest.opennlp.model.file.persons: en-ner-persons.bin
ingest.opennlp.model.file.dates: en-ner-dates.bin
ingest.opennlp.model.file.locations: en-ner-locations.bin

```

May be @spinscale has more ideas?

---

<div class="post-metadata">

**Author:** ![akml\_kk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akml_kk/32/31069_2.png) [@akml\_kk](https://discuss.elastic.co/u/akml_kk)\
**Post date:** [March 15, 2018, 10:19am UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/19 "2018-03-15T10:19:19Z")

</div>

Yes, it's French and an Arab name written in french.

The code that you ve post is what i've added to be able to use the plugin.

Did you mean that only works with english name and date and locations ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 15, 2018, 11:54am UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/20 "2018-03-15T11:54:42Z")

</div>

I don't know. That's just a guess and when @spinscale will be available, he will be able to answer.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 15, 2018, 8:35pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/21 "2018-03-15T20:35:18Z")

</div>

This depends on the model. The default model only works with english, but maybe there are other working with your languages of choice. You need to check the apache opennlp for that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 12, 2018, 8:44pm UTC](https://discuss.elastic.co/t/opennlp-dont-return-valid-result-in-pdf/123566/22 "2018-04-12T20:44:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
