【发布时间】:2018-01-15 13:57:31
【问题描述】:
我有一个句子,但是这个句子被分割成每个空格。
我的数据输出是这样的
const escapeRE = new RegExp(/([/\?""])/g);
const myDatas = data.map(des => des.Sentence.toLowerCase().replace(escapeRE, '').split(' '));
[ [ 'yes',
'keep',
'go',
'apple',
'tabacco',
'javascript',
'no',
'uhh',
'omg',
'hi.' ],
['say',
'hello',
'me',
'allright',
'maybe',
'mi',
'say.'
....] ]
比我有一个停用词JSON 文件。
停用词JSON文件的内容
['yes',
'hi',
'so',
'say',
'me',
'uhh',
'omg',
'go',
'hello',
'hi'
...]
所以我想从数组句子中删除停用词。
我想要纯句子,没有停用词。
stopwords定义;
const stopwords = require('./stop_words.json');
那我该怎么办?我没有任何想法。我尝试了myDatas.replace('stopwords', '' ) 函数,但它没用
【问题讨论】:
标签: javascript json regex reactjs stop-words