npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nlp_sf

v1.0.4

Published

natural language processing

Downloads

53

Readme

natural language processing

description

the Natural Language Processing tools under the nodeJs running time, including Chinese word segmentation, sentiment analysis and so on.

simple to use

let {oops} = require('nlp_sf');
console.log(oops.divide('这是待分词文本,调用oops接口直接分词并且统计词频。'));

installation

npm install nlp_sf

file structure

|
|
+--lib----系统支持库
|
|
+--assets----测试文件
|
|
+--examples----测试程序
|
|
+--index.js----程序入口
|
|
+--package.json
|
|
+--readme.md

api

nlpir

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();

oops

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));