0.1.8 • Published 7 years ago

@pg-english/entity v0.1.8

Weekly downloads
2
License
MIT
Repository
-
Last release
7 years ago

@pg-english/entity

pg-english

Process text to entity tokens.

const entity = require('@pg-english/entity');
// entity.process(<tokens>, <match fn>, [this]): Promise (processed tokens)
// entity(<text>, <match fn>, [this])
// -> Promise (processed text)

// <match fn>(<texts>)
// - texts: array of text
// -> Promise {type, value, hint, length}
// - type: token type (table/column/row)
// - value: token value
// - hint: token hint (identifies table)
// - length: token length (from start of texts)


function match(txts) {
  var txt = txts.join(' ');
  if(!txt.startsWith('ascorbic acid')) return Promise.resolve(null);
  return Promise.resolve({type: 'column', value: 'ASCORBIC ACID', length: 2});
};
await entity('lemon has ascorbic acid', match);
// lemon has ASCORBIC ACID

await entity('i love ascorbic acid. chilli has ascorbic ascorbic acid.', match);
// i love ASCORBIC ACID . chilli has ascorbic ASCORBIC ACID .
0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago