用 JavaScript 寫的 NLP Library

nlp-compromise/nlp_compromise 是一個 JavaScript 寫的 NLP library,網頁上給的用法也很特別...

過去式:

nlp.text('She sells seashells').to_past()
// She sold seashells

複數形:

nlp.noun("dinosaur").pluralize();
// "dinosaurs"

還有這種用法:

nlp.statement('She sells seashells').negate().text()
// She doesn't sell seashells

也有這種用法:

nlp.sentence('I fed the dog').replace('the [Noun]', 'the cat').text()
// I fed the cat

抓人出來:

nlp.text("Tony Hawk did a kickflip").people();
// [ Person { text: 'Tony Hawk' ..} ]

不定冠詞:

nlp.noun("vacuum").article();
// "a"

還可以猜性別?

nlp.person("Tony Hawk").pronoun();
// "he"

str2num:

nlp.value("five hundred and sixty").number;
// 560

好像是好玩的東西... XD

This entry was posted in Computer, Murmuring, Programming, Science, Social, Software and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *