
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
the Natural Language Processing tools under the nodeJs running time, including Chinese word segmentation, sentiment analysis and so on.
let {oops} = require('nlp_sf');
console.log(oops.divide('这是待分词文本,调用oops接口直接分词并且统计词频。'));
npm install nlp_sf
|
|
+--lib----系统支持库
|
|
+--assets----测试文件
|
|
+--examples----测试程序
|
|
+--index.js----程序入口
|
|
+--package.json
|
|
+--readme.md
description
the native Natural Language Processing tools.
loading
first you need to load nlpir. this is the preferred method:
let nlp = require('nlp_sf');
let {nlpir} = nlp;
optionally, you also can load nlpir by the method:
let {nlpir} = require('nlp_sf');
.init()
nlpir.init();
.exit()
nlpir.exit();
description
the interface of the Natural Language Processing.
loading
first you need to load oops. this is the preferred method:
let nlp = require('nlp_sf');
let {oops} = nlp;
optionally, you also can load oops by the method:
let {oops} = require('nlp_sf');
.divide(params, error)
simply, method to divide a string and return array consist of the top 100 words sort by frequency.
default error = false, not throw error.
let arr = oops.divide('这是待分词文本,调用oops接口直接分词并且统计词频。');
custom divide params:
default
dict = {},
query = {
top: 100,
freq: 0,
len: 1,
join: false,
tags: ['n', 'a']
}
set top is -999, export all keywords
text is either String or array
tags
let path = require('path');
let text = '这是待分词文本,调用oops接口直接分词并且统计词频。';
let userDict = '../assets/userDict.txt';
userDict = path.join(__dirname, userDict);
let dict = {
userDict: userDict,
userWord: ['两国关系 n']
};
let query = {
top: 20,
freq: 0,
len: 1,
join: true,
tags: ['n']
};
let params = {
text: text,
dict: dict,
query: query
}
let arr = oops.divide(params);
.sense(params)
simply, method to sense a string and return object consist of positive point and negative point.
let arr = oops.sense('这是待情感分析文本,调用oops接口分析并且返回情感分析结果。');
custom sense params:
let path = require('path');
let title = '情感分析';
let content = '这是待情感分析文本,调用oops接口分析并且返回情感分析结果。';
let target = '情感';
let userDict = '../assets/userDict.txt';
userDict = path.join(__dirname, userDict);
let params = {
content: content,
target: target,
title: title,
userDict: title
}
let obj = oops.sense(params);
.distinguish(array)
first update dict, second use distinguish
folder /lib/lexical store .yml dict, updateDict read the .yml dict , and update .txt dict store /lib/dict folder
let arr = oops.divide(params);
oops.updateDict();
console.log(oops.distinguish(arr));
.divdis(params)
divide + distinguish
first update dict, second use divdis
folder /lib/lexical store .yml dict, updateDict read the .yml dict , and update .txt dict store /lib/dict folder
oops.updateDict();
console.log(oops.divdis(arr));
FAQs
natural language processing
We found that nlp_sf demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.