Bing's Simple English Dictionary tool

Source: Internet
Author: User

Today, I see the "Simple translation Tool-Bing dictionary third-party API usage method" written by Friends of the garden, which is very good, so I wrote one in Python. The source code is as follows:

1 Importurllib.request2 ImportJSON3 4Serviceurl='http://xtk.azurewebsites.net/BingDictService.aspx?Word='5 6  whileTrue:7Word = input ('Please enter the English word:')8     ifLen (Word) < 1 :9          BreakTenurl = serviceurl +Word One     Try: AUH =urllib.request.urlopen (URL) -     except: -         Print('API error, please retry') the         Continue -data =Uh.read () -     Try: -JS = Json.loads (Data.decode ('Utf-8')) +     except: -JS ="' +  A     if(js["pronunciation"] ==None): at         Print("no matching words found") -  -     Else: -         Print("American Tone: [", js["pronunciation"]["AmE"],
"] English tone: [", js["pronunciation"]["BrE"],"]\n") - forDeinchjs["defs"]: - Print(de["POS"],de["def"]) in Print("\ n Example") - forSaminchjs["Sams"]: to Print("en:", sam["Eng"]) + Print("English:", sam["CHN"],"\ n") - Continue

The results of the program run are as follows:

Please enter the English word: python
American voice: [' pa?θɑn] English: [' pa?θ (?) N]

N. python; Nam Sze
Web python; Monty Python; Parker

Example
En:serpent blood spurted through the air, and in a minute, the huge python is dead.
Chinese: Snake blood is ejected in the air, and soon the Boa is dead.

En:suggests that Python Web services implementations were not the only ones have trouble with the air fare quote Servic E.
Chinese: It is pointed out that Pythonweb service implementation is not the only use of ticket quote service has difficulty.

En:another idea was to require Python owners to the their pets fitted with microchips.
Chinese: Another idea is to have snake owners give their pets a microchip.

EN:A Practice Millennium Python Seeing, changes into a elegant young man, spits to the borneol in his mouth.
Chinese: A giant python practicing thousands of years see, into a lightly moving young, the borneol spit into his mouth.

En:participants reacted to the meaning threat implicit in Python by handing out a larger notional punishment to a Lawbrea Ker.
Chinese: The reaction of the participants was that in the python a threatening threat was sent by a larger name to punish the perpetrators.

En:quite a number of Python programmers has recommended Spark to me.
Chinese: Many python programmers recommend Spark to me.

En:zhu went out to investigate, and there, a few paces from his door, he saw a huge python!
Chinese: wish to go out to see, just a few steps away from the door, he saw a python!

En:the balls disappeared, and the couple found a lumpy-looking carpet python nearby.
Chinese: The ball is missing, but the couple found a rugged carpet python nearby.

En:so, in a second study they used a description of a Monty Python sketch which participants weren ' t told were supposed to Be a joke.
English: So in the second experiment, they used a sketch describing the python, and the participants didn't think it was a joke.

En:the Scripts directory contains Python scripts used to install and uninstall the application.
English: The script directory contains Python scripts for installing and uninstalling applications.

Bing's Simple English Dictionary tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.