HIT-SCIR / ltp-cloud-api-tutorial

A various-language tutorial of LTP Cloud API.
www.ltp-cloud.com
71 stars 40 forks source link

UNAUTHORIZED error when using the urlbase #3

Closed MingleiLI closed 6 years ago

MingleiLI commented 8 years ago

It return "UNAUTHORIZED" error when using the url uri_base = "http://ltpapi.voicecloud.cn/analysis/?" It works fine with the url = "http://api.ltp-cloud.com/analysis/?" from the official website http://www.ltp-cloud.com/document/

fseasy commented 8 years ago

HI~ LTP CLOUD已经完成了更新,更新后使用新版api地址,即官方的地址:http://api.ltp-cloud.com/analysis/ 。 之前的地址是哈工大讯飞语言云,致力于稳定高并发的服务,现在的LTP CLOUD服务已经完成分离,原始数据已经导入到该api下,新的API提供语义依存分析(SDP)服务,致力于最新科研成果(LTP)的展示。 欢迎使用新版API,并提出宝贵的意见和反馈。

YUNFEILONG commented 8 years ago

Another issue; when using xml for pos tagging results, it only returns bad request error(Error 400), even we use the CustomPOSTags.py which provided in your offical github website.

fseasy commented 8 years ago

@YUNFEILONG Hi , I have test the CustomPOSTags.py file , just using right API_KEY for ltpapi.voicecloud.cn , I have get the default result . Then I have changed format from "conll" to "xml" , I still get an answer . Changing "dp" to "pos" also has been tested . So may you test agin or give more detail message ?

YUNFEILONG commented 8 years ago

Dear XU WEI: Is the uri_base equal to 'ltpapi.voicecloud.cn' or "http://api.ltp-cloud.com/analysis/?"?, I have use the later one because the former one seems not authorize me to call the api. but still I get the 'Bad request'. Is the problem because I use 'http://api.ltp-cloud.com/analysis/?' instead of 'ltpapi.voicecloud.cn', or because of other issues. Best wishes! YUNFEI LONG

fseasy commented 8 years ago

I am sorry for the confused situation . As far as I test , the api.ltp-cloud.com actually do not support customizing the input , that is , the field xml_input=true will cause the server in api.ltp-cloud.com return the wrong response . But the original(or the past , the another ...) service ltpapi.voicecloud.cn support it ! But the way to registrating the ltpapi.voicecloud.cn seems to be closed. ( At least , our ltp-cloud.com has cloused it).

I am wondering whether you need customizing the input , that is , you provide the word segmentation or even POS-TAG . it not , you may just need to using current api.ltp-cloud.com , and disabled xml_input(just omit it ) . It a customizing input is really needed , I'll try to get more information and give a nicer solution (it may be after 2016-01-03 , for the vacation )

More detailed infomation aboud api.ltp-cloud.com ,see 语言云文档 , only Chinese version is available currently .

At last , May I Ask , whether you know Chinese . A better and clearly information may be transport in Chinese For me ~

update: xml_input=True can work fine, see below.

fseasy commented 8 years ago

@YUNFEILONG By asking from @Oneplus , an access to the ltpapi.voicecloud.cn have been clearly found . Firstly , visit 讯飞语言云 and make an registion(click 登录/注册 in the top right corner) to create an account . Secondly , under the accout to click 创建新应用 to create an app(service) , choosing 语言云 and you 'll get an API_KEY to access the ltpapi.voicecloud.cn

hui001 commented 7 years ago

memeda: 你好,我想确认一下,现在 api.ltp-cloud.com 服务不提供用户自定义输入是么?比如在已经自定义分词的基础上再调用词性标注的服务。 谢谢

fseasy commented 7 years ago

@hui001 这个之前报过BUG,是XML随着模型更新后格式发生改变,原来校验XML正确性的代码还没有更新,但是具体哪里有问题我没有再细查了(= =), 我尽量这周末解决掉这个问题啊

hui001 commented 7 years ago

@memeda 好的,非常感谢~

fseasy commented 7 years ago

@hui001 找到问题了,非常简单... 请在输入自定义的XML时,保证note标签下包含以下全部属性:

<note sent="y" word="y" pos="n" ne="n" parser="n" semparser="n" lstmsemparser="y" srl="n" />

会报BAD XML FORMAT 错误就是因为检查到属性不全或者属性值与实际输入不同。 具体地,之前是没有"semparser" 和 "lstmsemparser"属性,所以因为属性缺失导致错误;(现在Python接口下自定义输入的XML格式已经更新了,详情查看commit 9cc8a95,可更新一下即可直接使用 ) 此外,如果属性值与输入的XML数据不同,也会报此错误。比如,如果pos="y",但是xml里并没有提供pos信息,那么就将报错。

hui001 commented 7 years ago

@memeda 收到,谢谢~

jiman0317 commented 7 years ago

您好,我在使用 CustomSegmentation.java的範例程式時,一直會有底下錯誤訊息: java.io.IOException: Server returned HTTP response code: 400 for URL: http://api.ltp-cloud.com/analysis/ at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) at LTP.CustomSegmentation.analyze(CustomSegmentation.java:133) at LTP.CustomSegmentation.main(CustomSegmentation.java:38)

我已經將note部分添加底下兩個敘述 Element note = document.createElement("note"); note.setAttribute("sent", "y"); note.setAttribute("word", "y"); note.setAttribute("pos", "n"); note.setAttribute("ne", "n"); note.setAttribute("parser", "n"); note.setAttribute("semparser", "n"); note.setAttribute("lstmsemparser", "y"); note.setAttribute("srl", "n"); xml4nlp.appendChild(note);

結果還是有以上的錯誤訊息出來,不知道這邊還需要修正哪裡,才可以成功?? 以上希望可以幫助一下,感恩:D

fseasy commented 7 years ago

@jiman0317

note.setAttribute("lstmsemparser", "y");

这里似乎应该是n,改下试试呢~

jiman0317 commented 7 years ago

@memeda 真的是如此呢,感謝! 直接看官方input結果以為是y,謝謝提醒!! 已經成功跑出來了:D

lmzl0302 commented 6 years ago

@memeda ,你好,打扰了。我也出现401的问题,但是我的网址已是"http://api.ltpcloud.com/analysis/?", api_key也没有问题,使用的python接口。请问是怎么回事?

fseasy commented 6 years ago

@lmzl0302 不好意思,我已经毕业了哈,没有能力再维护这个了 ⏲ @Oneplus 师兄看看组里谁在维护呢,麻烦给解答一下吧

lmzl0302 commented 6 years ago

谢谢,打扰你了。

jiman0317 commented 6 years ago

我覺得 你網址可以這樣改成 http>>https

我之前也會產生這種錯誤,不過 在http這邊 多+個s就解決了,但速度會比較慢。

lmzl0302 commented 6 years ago

太感谢了,真得解决了。