[Javascript] Identify the most important words in a document using tf-idf in Natural
JavaScript in The Using Document TF words most
2023-09-14 08:59:17 时间
Tf-idf, or term frequency-inverse document frequency, is a statistic that indicates how important a word is to the entire document. This lesson will explain term frequency and inverse document frequency, and show how we can use tf-idf to identify the most relevant words in a body of text.
Find specific words tf-idf for given documents:
var natural = require('natural'); var TfIdf = natural.TfIdf; var tfidf = new TfIdf(); tfidf.addDocument('this document is about node.'); tfidf.addDocument('this document is about ruby.'); tfidf.addDocument('this document is about ruby and node.'); tfidf.tfidfs('node ruby', function(i, measure) { console.log('document #' + i + ' is ' + measure); }); /* document #0 is 1 document #1 is 1 document #2 is 2 */
List most important words:
tfidf.listTerms(0 /*document index*/).forEach(function(item) { console.log(item.term + ': ' + item.tfidf); });
相关文章
- javascript 基础_JavaScript高级编程
- 【说站】JavaScript垃圾回收机制的分析
- ORA-32019: The parameter SPFILE cannot be updated in the server parameter file. ORACLE 报错 故障修复 远程处理
- ORA-48414: The string in the execution option exceeds maximum length [string] ORACLE 报错 故障修复 远程处理
- Ember.Js v2.14.0-beta.1 发布,一个JavaScript框架详解编程语言
- 的区别MySQL中ON与IN的区别探讨(mysql中on与in)
- 查询利用Oracle In查询实现列值范围筛选(oracle列值in)
- 查询MySQL中使用IN语句实现多字段查询(mysql多字段in)
- MySQL中IN查询的使用方法(mysql查询in)
- 深入Linux内核:IN后缀操作系统之旅(linux系统in后缀)
- MySQL中的IN命令:有效管理你的数据库(mysql in 命令)
- 如何有效运用SQL Server的IN语句(sqlserver用in)
- MySQL中的Out和In操作一个简单的指南(mysql中out in)
- MySQL中的IN语句是否能够走索引(mysql中in走索引么)
- MySQL中IN操作存在漏洞(mysql中in有漏)
- 深入剖析MySQL中IN和等于操作的差异与应用(mysql中in和等于)
- MySQL表中使用IN命令优化索引,提高查询效率(mysql中in命中索引)
- Oracle的IN走索引技术(in走索引 oracle)
- 查询Oracle IN查询两个字段的精彩之处(oracle两个字段in)
- javascript获取特定的CSS属性值
- javascript跨域的4种方法和原理详解
- ThinkPHP控制器里javascript代码不能执行的解决方法