BraveyJS / Bravey

A simple JavaScript NLP-like library to help you creating your own bot.
https://braveyjs.github.io/
MIT License
78 stars 6 forks source link

[enhancement] Improve the format of the property "entitiesIndex" #20

Open thiagodp opened 6 years ago

thiagodp commented 6 years ago

Given a entity foo and a sentence recognized as "A {foo} and a {foo} with a {bar}.", the property entitiesIndex (of the object returned by the test() method) will be something like:

{
  "foo": { position: 2, entity: "foo", ... },
  "foo1": { position: 15, entity: "foo", ... },
  "bar": { position: 24: entity: "bar", ... }
}

The second foo entity is represented by foo1. I think it is better having an array for each entity found:

{
  "foo": [ { position: 2, entity: "foo", ... },{ position: 15, entity: "foo", ... } ]
  "bar": [ { position: 24: entity: "bar", ... } ]
}

This makes it easier to get all the results of a certain entity as well as to count them.