Coder Social home page Coder Social logo

bosonnlp's Issues

运行例子显示<h2>Moved</h2>

运行:
var bosonnlp = require('bosonnlp');
var nlp = new bosonnlp.BosonNLP('这里是我的key');
nlp.ner('成都商报记者 姚永忠', function (result) {
console.log(result);
});

结果:
PS F:\workspace\bosonAPITest> node apiTest

Moved

运行例子显示{"status":403,"message":"malformed token format"}

在运行
from future import print_function, unicode_literals
import json
import requests

SENTIMENT_URL = 'http://api.bosonnlp.com/sentiment/analysis?weibo'
headers = {
'X-Token': 'YOUR_API_TOKEN',
'Content-Type': 'application/json'
}

s = ['他是个**']
data = json.dumps(s)
resp = requests.post(SENTIMENT_URL, headers=headers, data=data.encode('utf-8'))

print(resp.text)

显示了403

telnet api.bosonnlp.com 80显示
Trying 120.79.151.233...
Connected to aliyun-1500.bosondata.net.
Escape character is '^]'.
Connection closed by foreign host.

例子运行不了

nodejs_lib node index.js
events.js:141
throw er; // Unhandled 'error' event
^

Error: getaddrinfo ENOTFOUND api.bosonnlp.com api.bosonnlp.com:80
at errnoException (dns.js:27:10)
at GetAddrInfoReqWrap.onlookup as oncomplete
➜ nodejs_lib node index.js
{"status":403,"message":"malformed token format"}

suggest 方法返回502

你好,我尝试运行suggest 的方法,获取到的结果是502.

代码片段如下

const bosonnlp = require('bosonnlp')
const nlp = new bosonnlp.BosonNLP(bosonKey)

const term = '粉丝'
nlp.suggest(term, function (data) {
	console.log("suggest:", data)
})

返回结果如下:

suggest: <html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty/1.11.2.3</center>
</body>
</html>

encodeString didn't cater the case of data contains double quote character

During encoding the string that contains character double quote ("), it may construct a wrong http request body as for the API request.
It is because

function encodeString (data) { data = "\"" + escape(data).replace(/\%/g, '\\') + "\""; data = restorePunctuation(data); return data; };

It is easy to fix the issue. In the restorePunctuation function, make below changes:
OLD:
data = data.replace(/\\22/g, "\"");
NEW:
data = data.replace(/\\22/g, "\\\"");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.