The new FunctionEntityRecognizer allows to specify a function to detect entities. It is useful to deal with those cases in which a regular expression is hard to build.
As documented, the function expects a string and returns an array of { value: any, index: number }. Example:
var detectFoo = function( text ) {
var detected = [];
while ( the entity is detected in the text ) {
detected.push( {
value: <detected value here>,
index: <detected index here>
} );
}
return detected;
};
var reg = new Bravey.FunctionEntityRecognizer( "foo", detectFoo );
TypeScript definition file added, as proposed by the pull request 17 (@nippur72). Now it also contains FunctionEntityRecognizer.
The new
FunctionEntityRecognizer
allows to specify a function to detect entities. It is useful to deal with those cases in which a regular expression is hard to build.As documented, the function expects a string and returns an array of
{ value: any, index: number }
. Example:TypeScript definition file added, as proposed by the pull request 17 (@nippur72). Now it also contains
FunctionEntityRecognizer
.