让我们假设我有一个字符串并且想为 SEO 提取不常见的关键字。 $text = "这是一些文字。这是一些文字。自动售货机很棒。";
& 将定义一组常用词以忽略提取列表中的关键字,如 $commonWords = ['i','a','about','an','and','are',' as','at','be','by','com','de','en','for','from','how','in','is','it' ,'la','of','on','or','that','the','this','to','was','what','when','where','谁','将','与','und','the','www'];
预期输出:Result=[some,text,machines,vending]
如果有人能帮助我们编写从字符串中提取关键字的通用逻辑或过程,我们将不胜感激?
最佳答案
这会有所帮助(它支持多种语言):
https://github.com/michaeldelorenzo/keyword-extractor
var sentence = "President Obama woke up Monday facing a Congressional defeat that many in both parties believed could hobble his presidency."
// Extract the keywords
var extraction_result = keyword_extractor.extract(sentence,{
language:"english",
remove_digits: true,
return_changed_case:true,
remove_duplicates: false
});
关于javascript - 从字符串 : Javascript 中提取关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33430914/