Git Product home page Git Product logo

mtranslate's Introduction

mtranslate's People

Contributors

ehanhalici avatar jabbalaci avatar josephfrazier avatar mouuff avatar sven-mayer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mtranslate's Issues

Just an inquiry

Hey, Cool library, very useful. Just wanted to ask, since html parsing is used here.... Would HTML Parsing in this module be faster than using another module which uses rpc's to make requests from the server? Both are blazing fast but I just want to know if you guys might have some more insight.

Also, is it possible to set it to only use one gender-translation (if you try and translate "they" to french it will result in both gender translations since translate.google.com displays both in different fields the translation returns "ils ou elles" which means "they(m) or they(f)) so as to prevent the merging of two different gender translations into the returned translation.

Python 3 handling of unicode (non-ascii) text - with fix

The python3 version wasn't working for me with Arabic input language. It seems like it might be broken with all non ascii letter systems. However there is a way to first convert the text to an HTML escape code then send it to you function with the following code:

def convertUnicodeToHTMLEsc(text):
htmlEsc = str(text.encode()).replace("b'\x", "%").replace("\x", "%").replace("'", '')
return htmlEsc

then after the comment in your function put this line:
to_translate = convertUnicodeToHTMLEsc(to_translate)

I am more of a code hacker than a coder so there might be a easier way but this works.

Fine tuning mtranslate

Hello! I am new to NLP. Would like to ask is it possible to fine tune mtranslate with our own dataset prepared? Might I ask how to do it?

TypeError: 'NoneType' object is not callable

Traceback (most recent call last):
  File "C:\Users\localadmin\AppData\Roaming\Python\Python39\site-packages\guilded\__main__.py", line 201, in websocket_process
    await c(*ctx.arguments)
  File "c:\RitaBot\PythonGuilded\bot.py", line 45, in translate
    translate1 = translate(argstr, Lang, "auto")
TypeError: 'NoneType' object is not callable

I'm using it like follows:

import mtranslate
from mtranslate import translate

def converttostr(input_seq, seperator):
  # Join all strings in list
  final_str = seperator.join(input_seq)
  return final_str

def translate(ctx, *args):
    message = ctx.message.content
    message = message[11:]
    msgList = message.split()
    Lang = msgList[0]

    del msgList[0]

    seperator=" "
    argstr = converttostr(input_seq=msgList, seperator=seperator)
    print(Lang)
    print(argstr)

    translate1 = translate(argstr, Lang, "auto")
    print(translate1)

I've tried just adding in static strings instead of splitting up arguments from another library and same error.

Anyone have any solution?

can't insert inside of facebook chatbots

from mtranslate import translate
x = message_text
def main():
to_translate = x
x1 =(translate(to_translate))
x2 =(translate(to_translate, 'ar'))

x = x1 + "     " + x2

if name == 'main':
main()

Gives me an error after 266 translations

After 266 translation calls (in a for-loop) I get always the following error (it's always exactly 266). Do you know why?

Traceback (most recent call last):
  File "/Users/username/PycharmProjects/Translation/GoogleTranslator.py", line 52, in <module>
    review_trans = translate(review, 'en')
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mtranslate/core.py", line 70, in translate
    page = urllib.request.urlopen(request).read().decode("utf-8")
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

Parameter Adjustment Needed

Google changed it's parameters and the result page sometimes looks different. The following changes are necessary:

1.) ht -> tl
base_link = "http://translate.google.com/m?tl=%s&sl=%s&q=%s"

  1. the regex needs to test for two classes and may include newlines
    expr = r'(?s)class="(?:t0|result-container)">(.*?)<'

urlopen error WinError 10060 when using mtranslate

Not sure if someone is still monitoring this project, but I'm getting the following error when using the translate option

<urlopen error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>

Eventually works after trying a few more times and finishes successfully, but why is failing when my machine is online, is this hitting some sort of limit? any options around that?

Thanks.

How to fix this error?

File "/opt/virtualenvs/ros/local/lib/python2.7/site-packages/mtranslate/core.py", line 72, in translate
to_translate = urllib.quote_plus(to_translate)
File "/usr/lib/python2.7/urllib.py", line 1299, in quote_plus
s = quote(s, safe + ' ')
File "/usr/lib/python2.7/urllib.py", line 1294, in quote
return ''.join(map(quoter, s))
KeyError: u'\xe8'
I think this because I need to use unicode.
It's possible to use unicode?

Not translating any more

It was working very well until recently, then it stopped translating when I checked today.

I donʻt think this is my IP blocked because I did not use it that much.

Does not show any warning/error message, just returns an empty string.

Handle the translate for the input characters more than 5000

First, I appreciate the author and contributors for the great and cool work done here!
Out of a curious experiment, I tried to translate srt file (Movie subtitle file). Tried to translate English to Tamil
It is expected that the google translate will support the input up to 5000 characters, but the library could be

  1. enhanced to accept and handle the characters more than 5000 with internal split, process, append and return (or)
  2. can have a defensive approach with print statement about the acceptable string length and process the translate up to 5000 characters and return

Now the library is translating up to characters 5000 but if we tried to run more than 5000 (Even 5001), it returns None
I can handle the limitations as per my requirement locally, but I am just notifying here

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.