10000 Add Yandex Translate API support by wdv4758h · Pull Request #127 · zdict/zdict · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Add Yandex Translate API support #127

Merged
merged 8 commits into from
Aug 30, 2017
Merged

Add Yandex Translate API support #127

merged 8 commits into from
Aug 30, 2017

Conversation

wdv4758h
Copy link
Member

@wdv4758h
Copy link
Member Author

Yandex Dictionary API should fit better to our need, but I can't get the API key, it didn't send the SMS verification code to my phone :P

@iblislin
Copy link
Member

linter failure on travis



# The daily request limit is 1,000,000 characters. The monthly limit is 10,000,000 characters.
API_KEY = 'trnsl.1.1.20170826T075621Z.6dfcaff242c6caa8.e2b9cf136d451d9d6eb69516ec97b827e8c8229b'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API_KEY = (
    'trnsl.1.1.20170826T075621Z.'
    '6dfcaff242c6caa8.e2b9cf136d451d9d6eb69516ec97b827e8c8229b')

# Need to keep the `{word}` for `_get_url()` usage.
# TODO: support different translate direction
# TODO: use Dictionary API
API = 'https://translate.yandex.net/api/v1.5/tr.json/translate?key={api_key}&text={word}&lang=ru-en'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as previous remark

@wdv4758h
Copy link
Member Author

yep modifing code, just open the WIP PR, and I will add a test case later.

@iblislin
Copy link
Member
iblislin commented Aug 26, 2017

there are lots of TODO tags in the code.
mark this PR as WIP?

@wdv4758h
Copy link
Member Author

and I think we should update some dependencies :P

@iblislin
Copy link
Member
iblislin commented Aug 26, 2017

and I think we should update some dependencies :P

maybe in separated PR, for traceable commit history


# The daily request limit is 1,000,000 characters
# The monthly limit is 10,000,000 characters
API_KEY = 'trnsl.1.1.20170826T075621Z.' \
Copy link
Member
@iblislin iblislin Aug 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:/ I'm not a fan of escaping newline.
But I'm ok, if you do not like string concatenation within ().

@wdv4758h
Copy link
Member Author

and I think we should update some dependencies :P

maybe in separated PR, for traceable commit history

yes, I expect it in another PR

'6dfcaff242c6caa8.e2b9cf136d451d9d6eb69516ec97b827e8c8229b'


# Change `Template` to the name of new dictionary. like xxxDict.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless comment?

@iblislin iblislin changed the title Add Yandex Translate API support WIP: Add Yandex Translate API support Aug 26, 2017
content = self._get_raw(word)
content_json = json.loads(content)

if not content_json['code'] != '200':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it's combining not and != ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's a copy paste mistake 🍸

@iblislin
Copy link
Member

what's wrong with Travis on python 3.6? :/

@coveralls
Copy link
coveralls commented Aug 26, 2017

Coverage Status

Coverage decreased (-0.9%) to 84.364% when pulling 7f79720 on yandex into 0fcbf51 on master.

@iblislin
Copy link
Member
iblislin commented Aug 26, 2017
  • test cases

@wdv4758h
Copy link
Member Author

Python 3.6 on Travis CI is a shit !?

Copy link
Member
@iblislin iblislin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep this PR open a few days for reviewing

@wdv4758h
Copy link
Member Author

I wonder why I can not get the verification code for the signup of Yandex Dictionary API 😢

@wdv4758h
Copy link
Member Author

dude, why Travis CI is angry with Python 3.6 !?

6D40

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 85.837% when pulling 7bbed10 on yandex into 0fcbf51 on master.

@zdict zdict deleted a comment from coveralls Aug 26, 2017
@zdict zdict deleted a comment from coveralls Aug 26, 2017
@zdict zdict deleted a comment from coveralls Aug 26, 2017
@iblislin
Copy link
Member

Travis refused to update setuptools?

status,
'Some bad thing happened with Yandex'
)
print('Yandex: ' + message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print('Yandex:', message)?
print will append a space for you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the concat by +, but if you like that one I can change it.

@wdv4758h
Copy link
Member Author

TODO:

  • let user can choose the translate direction, e.g. 'ru-en', 'en-ru', 'es-en', 'en-es'
  • support Yandex Dictionary API

these two things won't be done very quick, I'm going to leave it in the future 😝

@iblislin
Copy link
Member

nice screenshot. add it to README?

@wdv4758h
Copy link
Member Author

supported languages in Yandex Translate API: https://translate.yandex.net/api/v1.5/tr.json/getLangs?key={api_key}

{"dirs":["az-ru","be-bg","be-cs","be-de","be-en","be-es","be-fr","be-it","be-pl","be-ro","be-ru","be-sr","be-tr","bg-be","bg-ru","bg-uk","ca-en","ca-ru","cs-be","cs-en","cs-ru","cs-uk","da-en","da-ru","de-be","de-en","de-es","de-fr","de-it","de-ru","de-tr","de-uk","el-en","el-ru","en-be","en-ca","en-cs","en-da","en-de","en-el","en-es","en-et","en-fi","en-fr","en-hu","en-it","en-lt","en-lv","en-mk","en-nl","en-no","en-pt","en-ru","en-sk","en-sl","en-sq","en-sv","en-tr","en-uk","es-be","es-de","es-en","es-ru","es-uk","et-en","et-ru","fi-en","fi-ru","fr-be","fr-de","fr-en","fr-ru","fr-uk","hr-ru","hu-en","hu-ru","hy-ru","it-be","it-de","it-en","it-ru","it-uk","lt-en","lt-ru","lv-en","lv-ru","mk-en","mk-ru","nl-en","nl-ru","no-en","no-ru","pl-be","pl-ru","pl-uk","pt-en","pt-ru","ro-be","ro-ru","ro-uk","ru-az","ru-be","ru-bg","ru-ca","ru-cs","ru-da","ru-de","ru-el","ru-en","ru-es","ru-et","ru-fi","ru-fr","ru-hr","ru-hu","ru-hy","ru-it","ru-lt","ru-lv","ru-mk","ru-nl","ru-no","ru-pl","ru-pt","ru-ro","ru-sk","ru-sl","ru-sq","ru-sr","ru-sv","ru-tr","ru-uk","sk-en","sk-ru","sl-en","sl-ru","sq-en","sq-ru","sr-be","sr-ru","sr-uk","sv-en","sv-ru","tr-be","tr-de","tr-en","tr-ru","tr-uk","uk-bg","uk-cs","uk-de","uk-en","uk-es","uk-fr","uk-it","uk-pl","uk-ro","uk-ru","uk-sr","uk-tr"]}

Currently, I only implement the ru-en support.

@coveralls
Copy link
coveralls commented Aug 26, 2017

Coverage Status

Coverage increased (+0.5%) to 85.714% when pulling af66df3 on yandex into 0fcbf51 on master.

@wdv4758h
Copy link
Member Author

I'll rebase the PR after this one #128, the testing will be good after that

@wdv4758h
Copy link
Member Author

Rebased, let's see the new test result 😝

@coveralls
Copy link
coveralls commented Aug 27, 2017

Coverage Status

Coverage increased (+0.5%) to 85.714% when pulling c0daf1e on yandex into c930d39 on master.

@wdv4758h wdv4758h changed the title WIP: Add Yandex Translate API support Add Yandex Translate API support Aug 27, 2017
@wdv4758h
Copy link
Member Author

Test passed, but I will leave it here for a few days to let everyone aware this.

@iblislin iblislin removed the WIP label Aug 27, 2017
@iblislin
Copy link
Member

oh, you need to update the usage section of README as well.

@wdv4758h
Copy link
Member Author

thanks for remind

@coveralls
Copy link
coveralls commented Aug 27, 2017

Coverage Status

Coverage increased (+0.5%) to 85.714% when pulling 46963f9 on yandex into c930d39 on master.

Copy link
Member
@fkztw fkztw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we need a coding style guide. lol

@fkztw
Copy link
Member
fkztw commented Aug 29, 2017

I think we should bump to 0.10.0 after merge this PR?

@iblislin
Copy link
Member

I think we should bump to 0.10.0 after merge this PR?

I'm fine with that

@wdv4758h wdv4758h merged commit ed208eb into master Aug 30, 2017
wdv4758h added a commit that referenced this pull request Aug 30, 2017
* [#127] Add Yandex Translate API support
* [#128] Upgrade all dependencies
@wdv4758h wdv4758h mentioned this pull request Aug 30, 2017
@iblislin iblislin deleted the yandex branch August 30, 2017 15:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0