# Differerences between Portuguese and Brazilian stemmer

**URL:** <https://discuss.elastic.co/t/differerences-between-portuguese-and-brazilian-stemmer/153364>\
**Category:** Elasticsearch\
**Created:** [October 22, 2018, 9:39am UTC](https://discuss.elastic.co/t/differerences-between-portuguese-and-brazilian-stemmer/153364 "2018-10-22T09:39:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmchugh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmchugh/32/97131_2.png) [@rmchugh](https://discuss.elastic.co/u/rmchugh)\
**Post date:** [October 22, 2018, 9:39am UTC](https://discuss.elastic.co/t/differerences-between-portuguese-and-brazilian-stemmer/153364/1 "2018-10-22T09:39:58Z")

</div>

What are the main differences between the Portuguese and Brazilian language analyzers in 6.x? I've run into some rather strange behaviour when implementing Brazilian and I'm wondering is there any benefit to using the Brazilian analyzer versus the Portuguese one for Brazilian text. The below example shows some weird behaviour when stemming plural forms:

The Portuguese analyzer stems `animais` to `animal` so searches for `animal` will retrieve `animais` and vice versa. But the Brazilian stemmer stems `animais` to `anim` but doesn’t stem `animal` so these searches won't work. What is the reason for this behaviour?

Portuguese:

```
curl -s -X GET "http://localhost:9200/_analyze" -H 'Content-Type: application/json' -d'
{
  "analyzer" : "portuguese",
  "text" : "animal animais"
}
' | jq .

{
  "tokens": [
    {
      "token": "animal",
      "start_offset": 0,
      "end_offset": 6,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "animal",
      "start_offset": 7,
      "end_offset": 14,
      "type": "<ALPHANUM>",
      "position": 1
    }
  ]
}

```

Brazilian

```
curl -s -X GET "http://localhost:9200/_analyze" -H 'Content-Type: application/json' -d'
{
  "analyzer" : "brazilian",
  "text" : "animal animais"
}
' | jq .

{
  "tokens": [
    {
      "token": "animal",
      "start_offset": 0,
      "end_offset": 6,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "anim",
      "start_offset": 7,
      "end_offset": 14,
      "type": "<ALPHANUM>",
      "position": 1
    }
  ]
}
```

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [October 22, 2018, 10:26am UTC](https://discuss.elastic.co/t/differerences-between-portuguese-and-brazilian-stemmer/153364/2 "2018-10-22T10:26:38Z")

</div>

Hi @rmchugh

this is an interesting observation, I would also have expected for the both stemmers to work the same way, but then I don't know enough about the similarity and subtle differences of Portuguese and Brazilian Portuguese.

Elasticsearch uses the Stemmers available in the Lucene project, and the two implementations might differ slightly in either implementation or the resources they use (e.g. dictionaries etc.):

[https://lucene.apache.org/core/7\_2\_1/analyzers-common/org/apache/lucene/analysis/pt/PortugueseStemmer.html](https://lucene.apache.org/core/7_2_1/analyzers-common/org/apache/lucene/analysis/pt/PortugueseStemmer.html)

[https://lucene.apache.org/core/7\_2\_1/analyzers-common/org/apache/lucene/analysis/br/BrazilianStemmer.html](https://lucene.apache.org/core/7_2_1/analyzers-common/org/apache/lucene/analysis/br/BrazilianStemmer.html)

By looking at the code I can see that `PortugueseStemmer extends RSLPStemmerBase` but `BrazilianStemmer` is just its own class. It looks much more basic to me, but that's just a guess. To get more information about the stemmer implementations and their advantages and shortcomings I'd suggest asking on the [Lucene user mailinglist](https://lucene.apache.org/core/discussion.html) or even try to contact the authors of the individual stemmers. Looking at the git history of both classes there doesn't seem to be much going on in the last few years though...

---

<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:** [November 19, 2018, 10:37am UTC](https://discuss.elastic.co/t/differerences-between-portuguese-and-brazilian-stemmer/153364/3 "2018-11-19T10:37:52Z")

</div>

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