winkjs / wink-nlp-utils

NLP Functions for amplifying negations, managing elisions, creating ngrams, stems, phonetic codes to tokens and more.
http://winkjs.org/wink-nlp-utils/
MIT License
119 stars 12 forks source link

Consider composeCorpus to receive array<array<string>> #25

Closed labs20 closed 4 years ago

labs20 commented 4 years ago

Like this:

composeCorpus( [
    ['I'], 
    ['am having', 'have'], 
    ['a'], 
    ['problem', 'question']
]);

This allows to feed it with a pre cached dictionary without having to format strings to feed it.

sanjayaksaxena commented 4 years ago

Hello @labs20

You can accomplish this via wink-helpers:

const helpers = require( 'wink-helpers' );
const corpus = [
    ['I'], 
    ['am having', 'have'], 
    ['a'], 
    ['problem', 'question']
];
console.log( helpers.array.product( corpus ) );

It will produce the following output:

[
  ["I", "am having", "a", "problem"]
  ["I", "am having", "a", "question"]
  ["I", "have", "a", "problem"]
  ["I", "have", "a", "question"]
]

Hope it meets your immediate need!

Best, Sanjaya

labs20 commented 4 years ago

Mmmm... guess I have to read the docs better, eh? ;]

Thanks!