I started doing NLP operation for a NodeJS app; The idea is to analyze some text and classify words as a verb, adjective, adverb, etc.
I found wordpos
and it responds completely to my needs:
https://www.npmjs.com/package/wordpos
I am trying to create a process function to create a keyword list using Wordpos.
My code is:
let content = lines.map(line => {
let element = line.split("=");
return {
name: element[0],
content: element[1],
keyword: process(element[1])
}
});
All functions of Wordpos require a callback. Promises can be used too to do some functions chaining. I understand that its operations need to hit wordnet-db so it works is async. Or I need to make sync calls and get results before going to the next steps of my code.
wordpos.getPOS(text, console.log);
{
nouns:[],
verbs:[],
adjectives:[],
adverbs:[],
rest:[]
}
I tried to create async/ await
calls but it's not working:
async function f(text) {
return await wordpos.getPOS(text);
}
console.log(f('The angry bear chased the frightened little squirrel'));
And result is:
node api_data.js
Promise { }