日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

微软翻译api的使用介绍和注意事项

發布時間:2023/12/4 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 微软翻译api的使用介绍和注意事项 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?google翻譯api已經收費了,而微軟翻譯api目前是免費的,支持幾種不同的方式訪問,如果感興趣可以自己封裝下協議處理。官方介紹:

http://msdn.microsoft.com/en-us/library/hh454950.aspx。

這里介紹一下java下的使用。Java下使用微軟翻譯api可以直接使用一個開源的sdkhttp://code.google.com/p/microsoft-translator-java-api/

?

?一、首先去http://code.google.com/p/microsoft-translator-java-api/,下載相關jar文件,這里有對微軟翻譯api的詳細使用有作詳細介紹。?

?? 二,去申請key,進入http://www.bing.com/developers/createapp.aspx,填寫相關的你的應用信息就行了。就會有下面的圖片中顯示的key,中的Application ID就是key。?

? 三、下面給個實例:?

Java代碼??

  • ??/**????
  • *?@Title:?MicroTranslate.java??
  • *?@Description:?TODO(用一句話描述該文件做什么)??
  • *?@author?zengzhaoshuai????
  • *?@date?2012-2-13?下午1:17:07??
  • *?@version?V1.0????
  • */??
  • ??
  • import?com.memetix.mst.language.Language;??
  • import?com.memetix.mst.translate.Translate;??
  • ??
  • /**??
  • ?*?@ClassName:?MicroTranslate??
  • ?*?@Description:?TODO(這里用一句話描述這個類的作用)??
  • ?*?@author?zengzhaoshuai??
  • ?*?@date?2012-2-13?下午1:17:07??
  • ?*???
  • ?*/??
  • public?class?MicroTranslate?{??
  • ????public?static?void?main(String[]?args)?throws?Exception?{??
  • ????????//?Set?the?Microsoft?Translator?API?Key?-?Get?yours?at?http://www.bing.com/developers/createapp.aspx??
  • ???????//?Translate.setKey(/*?Enter?your?API?Key?here?*/);??
  • ????????Translate.setKey("自己申請的key");??
  • ??
  • ????????String?translatedText?=?Translate.execute("屬性",?Language.CHINESE_SIMPLIFIED,?Language.ENGLISH);??
  • ??
  • ????????System.out.println(translatedText);??
  • ????}??
  • ??
  • }??
  • ?

    四、運行結果:Property?

    ?

    這里說下可能出現的問題:

    1android下要用microsoft-translator-java-api-0.6-jar-with-dependencies.jar,否則運行時可能會報錯android java.lang.NoClassDefFoundError: org.json.simple.JSONValue

    2、使用過程中出現錯誤:TranslateApiException: Cannot find an Azure Market Place Translator Subscription associated with the request credentials,則需要到網址上先訂閱translate api的免費流量,操作如下:

    Make sure you login to azure market place ?click on data and select Microsoft Translator. Now click on 2000000 c/moth @ $0 update option. Now I think this error will go away. Try following link also. This is the link where I signed up for 2000000 c/month offer. I was facing the same problem but when I updated my account through following link, this error went away.(參考:http://social.msdn.microsoft.com/Forums/zh-CN/microsofttranslator/thread/1eeb0066-553f-4523-9a1b-0976e4205bb2)

    轉載于:https://www.cnblogs.com/brainy/archive/2012/05/24/2516487.html

    總結

    以上是生活随笔為你收集整理的微软翻译api的使用介绍和注意事项的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。