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

bosonnlp

v0.1.0

Published

bosonnlp node sdk.

Downloads

8

Readme

BosonNLP

BosonNLP is a node sdk for http://bosonnlp.com .

Build Status npm NPM Downloads

Installation

$ npm install bosonnlp

Usage

var bosonnlp = require('bosonnlp');
var nlp = new bosonnlp.BosonNLP('YOUR_API_KEY');
nlp.ner('成都商报记者 姚永忠', function (result) {
	console.log(result);
});
//[{"tag": ["ns", "n", "n", "nr"], 
//  "word": ["成都", "商报", "记者", "姚永忠"], 
//  "entity": [[0, 2, "product_name"], [3, 4, "person_name"]]}]

API

  • tag(content, callback) - Tokenization and part of speech tagging.
  • ner(content, callback) - Named-entity recognition.
  • extractKeywords(content, callback) - Tokenization and compute word weight.
  • sentiment(content, callback) - Automatic detection of opinions embodied in text.
  • depparser(content, callback) - Work out the grammatical structure of sentences
  • classify(content, callback) - categorization the given articles.
  • suggest(term, callback) - Get relative words.

tag

POS Tagging DOC

var bosonnlp = require('bosonnlp');
var nlp = new bosonnlp.BosonNLP('YOUR_API_KEY');

var text = "这个世界好复杂";
boson.tag(text, function (data) {
	console.log(data);
});
// [{"tag": ["r", "n", "d", "a"], 
// "word": ["这个", "世界", "好", "复杂"]}]

var text = ['这个世界好复杂', '计算机是科学么'];
boson.tag(text, function (data) {
	data = JSON.parse(data); 

	// ["r", "n", "d", "a"]
	console.log(data[0].tag); 

	// ["这个", "世界", "好", "复杂"]
	console.log(data[0].word); 

	// ["n", "vshi", "n", "y"]
	console.log(data[1].tag); 

	// ["计算机", "是", "科学", "么"]
	console.log(data[1].word); 
});

ner

var bosonnlp = require('bosonnlp');
var nlp = new bosonnlp.BosonNLP('YOUR_API_KEY');
nlp.ner('成都商报记者 姚永忠', function (result) {
	console.log(result);
});
//[{"tag": ["ns", "n", "n", "nr"], 
//  "word": ["成都", "商报", "记者", "姚永忠"], 
//  "entity": [[0, 2, "product_name"], [3, 4, "person_name"]]}]

var content = ["对于该小孩是不是郑尚金的孩子,目前已做亲子鉴定,结果还没出来,",
                "纪检部门仍在调查之中。成都商报记者 姚永忠"];
nlp.ner(content, function (result) {
	console.log(result);
});
//[{"tag": ["p","r","n","vshi","d","vshi","nr","ude","n","wd","t","d","v","n","n","wd","n","d","d","v","wd"],
//  "word": ["对于","该","小孩","是","不","是","郑尚金","的","孩子",",","目前","已","做","亲子","鉴定",",",
// "结果","还","没","出来",","], 
//  "entity": [[6, 7, "person_name"]]},
//  {"tag": ["n","n","d","p","v","f","wj","ns","n","n","nr"], 
//  "word": ["纪检","部门","仍","在","调查","之中","。","成都","商报","记者","姚永忠"], 
//  "entity": [[7,9,"product_name"],[9,10,"job_title"],[10,11,"person_name"]]}]

extractKeywords

var bosonnlp = require('bosonnlp');
var nlp = new bosonnlp.BosonNLP('YOUR_API_KEY');
var text = ["病毒式媒体网站:让新闻迅速蔓延"];
nlp.extractKeywords(text, function (data) {
	data = JSON.parse(data);
	console.log(data);
});

sentiment

var text = ['他是个傻逼','美好的世界'];
boson.sentiment(text, function (data) {
    // [非负面概率, 负面概率]
    // [[0.6519134382562579, 0.34808656174374203], [0.92706110187413, 0.07293889812586994]]
	console.log(data);
});

depparser

Depparser Doc

名称 | 解释 |举例 ----|--------|--- ROOT | 核心词 | 警察打击犯罪。 SBJ | 主语成分 | 警察打击犯罪。 OBJ | 宾语成分 | 警察打击犯罪。 PU | 标点符号 | 你好*!* TMP | 时间成分 | 昨天下午下雨了。 LOC | 位置成分 | 我在北京开会。 MNR | 方式成分 | 我以最快的速度冲向了终点。 POBJ | 介宾成分 | 他对客人很热情。 PMOD | 介词修饰 | 这个产品到今天才完成。 NMOD | 名词修饰 | 这是一个错误。 VMOD | 动词修饰 | 我狠狠地他。 VRD | 动结式 | (第二动词为第一动词结果) 福建省涌现出大批人才。 DEG | 连接词| “的”结构 的妈妈是超人。 DEV | “地”结构| 他狠狠地看我一眼。 LC | 位置词结构 | 我在书房里吃饭。 M | 量词结构 | 我有只小猪。 AMOD | 副词修饰 | 一批中企业折戟上海。 PRN | 括号成分 | 北京(首都)很大。 VC | 动词| “是”修饰 我把你看做是妹妹。 COOR | 并列关系 | 希望能贯彻 执行该方针 CS | 从属连词成分 | 如果可行,我们进行推广。 DEC | 关系从句| “的” 这是以前不曾遇到过的情况。

var text = ['我以最快的速度吃了午饭']
boson.depparser(text, function (data) {
	console.log("depparser:", data);
});

classify

Classes Doc

编号 | 分类 ----|---- 0 | 体育 1 | 教育 2 | 财经 3 | 社会 4 | 娱乐 5 | 军事 6 | 国内 7 | 科技 8 | 互联网 9 | 房产 10 | 国际 11 | 女人 12 | 汽车 13 | 游戏

var text = ['俄否决安理会谴责叙军战机空袭阿勒颇平民',
			'邓紫棋谈男友林宥嘉:我觉得我比他唱得好',
			'Facebook收购印度初创公司'];
boson.classify(text, function (data) {
    // [5, 4, 8]
	console.log("classify:", data);
	test.done();
});

suggest

var term = '粉丝';
boson.suggest(term, function (data) {
	console.log("suggest:", data);
});

var options = {};
// options.top_k default 10
options.top_k = 2;
boson.suggest(term, options, function (data) {
	console.log("suggest:", data);
});