我想将一些缩写词转换为字符串句子的完整词,使NodeJS中的句子变得简单明了

例如

i'm => I am
i've => I have
w'ill => we will
lets => Let us
it's => It is


我已经安装了gingerbread,并且使用此模块,它仅检查语法错误。是否有任何模块可用于处理这样的文本?

最佳答案

英语中的缩写形式称为收缩。
您可以将收缩npm模块用于您的目的npm install contractions

使用起来非常简单。快速示例:

let contractions = require('contractions');

console.log(contractions.expand("I don't know who ya'll are."));
// Outputs: I do not know who you all are.

console.log(contractions.contract("You all will have not seen this."));
// Outputs: Y'all'll'ven't seen this.


您可以在这里https://www.npmjs.com/package/contractions找到更多信息

关于javascript - NodeJS-所有短(缩写)词到全词功能模块,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39660813/

10-11 15:37