Giter VIP home page Giter VIP logo

mymemopy's Introduction

Mymemopy

Allows you to translate phrases or text using Mymemory API.

Installation

Just run on terminal this command: $ pip install mymemopy and enjoy.

Usage

Just import the MyMemoryTranslate class and use the translate method, provide the text, source_lang and target_lang parameters, wait for the API response and get your translation.

The API accepts two types of users: Valid User (who uses a validated email or API key) and Anonymous User (who does not have an email or key). Both have character limitations per day for each translation. See more details.

Example of use

>>> from mymemopy.translator import MyMemoryTranslate
>>>
>>> def valid_user():
...     vu = MyMemoryTranslate(user_email='[email protected]')
...     print(vu)
...     print(vu.get_quota())
...     res = vu.translate(text='hola', source_lang='es', target_lang='en')
...     print(res)
...     print(vu)
...
>>>
>>> def anon_user():
...     au = MyMemoryTranslate()
...     print(au)
...     print(au.get_quota())
...     res = au.translate(text='hola', source_lang='es', target_lang='en')
...     print(res)
...     print(au)
...
>>>
>>>
>>> valid_user()
User: UserValid, Usage: 20, Limit: 50000, Email: example@example.com
20
hello.
User: UserValid, Usage: 24, Limit: 50000, Email: example@example.com
>>>
>>> anon_user()
User: Anonymous, Usage: 4, Limit: 5000, Email: None
4
hello.
User: Anonymous, Usage: 8, Limit: 5000, Email: None
>>>

MyMemory: API technical specifications

Get

Searches MyMemory for matches against a segment.

Call example:

https://api.mymemory.translated.net/get?q=Hello World!&langpair=en|it

**Parameter** **Description** **Type** **Example value**
q The sentence you want to translate. Use UTF-8. **Max 500 bytes** Mandatory Hello World!
langpair Source and language pair, separated by the | symbol. Use ISO standard names or RFC3066 Mandatory en|it
mt Enables Machine Translation in results. You can turn it off if you want just human segments Optional 1 (default), 0
key Authenticates the request; matches from your private TM are returned too. **Get your key [here](keygen.php) or use the keygen API** Optional
onlyprivate If your request is authenticated, returns only matches from your private TM Optional 0 (default), 1
ip The IP of the end user generating the request. **Recommended for CAT tools and high volume usage** Originating IP is always overridden by _X-Forwarded-For_ header, if the latter is set Optional 93.81.217.71
de A valid email where we can reach you in case of troubles. **Recommended for CAT tools and high volume usage** Optional [email protected]
user Authenticates the request; matches from your private TM are returned too Optional, but needs the key parameter. Kept for backward compatibility only: now the **key** parameter alone is sufficient

Keygen

Generates the key associated with a username.

Call example:

https://api.mymemory.translated.net/keygen?user=username&pass=password

Parameter description:

Parameter Description Type Example value
user The username whose key we want to generate Mandatory
pass The password associated with the username Mandatory

API usage limits

Get

Searches MyMemory for matches against a segment.

MyMemory tracks it usage in words. This means that it doesn't matter how many requests you submit to consult the archive, but the weight of each request.

Free, anonymous usage is limited to 5000 chars/day.

Provide a valid email ('de' parameter), where we can reach you in case of troubles, and enjoy 50000 chars/day.

Are you a CAT tool maker? Get whitelisted! Write us and get 150000 chars/day!*

If you are interested in even larger volumes, have a look at our RapidAPI plans!

Don't forget to check out carefully our Terms of Service, also.

  • Note for developers: Please bear in mind that we are eager to include in whitelisting program only estabilished projects of interest (have a look at "Most popular CAT tools" under CAT section, to get an idea of required market share). Personal projects or "in development" stuff, projects that just use the "get" endpoint without contributing to MyMemory using the "set" endpoint, never qualify for the whitelisting. Requests failing in complying with such minimum directive will be disregarded.

Keygen

Generates the key associated with a username.

To prevent abuse, we keep track of call rate and enforce limits when necessary.

Set

Contributes a translation unit (segment and translation) in some language pair to MyMemory.

This is never limited.

mymemopy's People

Contributors

kurotom avatar

Watchers

 avatar

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.