Carleslc / java-google-translate-text-to-speech

Automatically exported from code.google.com/p/java-google-translate-text-to-speech
1 stars 0 forks source link

Sentences are cut off after a comma, questionmark and such #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to translate any sentence that include a comma (",")

What is the expected output? What do you see instead?
I would expect a translation of the complete sentence, but only the first one 
is returned.

What version of the product are you using? On what operating system?
Latest version on android 2.1

Please provide any additional information below.
I've been using this code for an application in c#. Here the changelog says 
"Fixed bug that limited translation to first sentence". I'm sorry I don't know 
what he did, but maybe it's the same problem here. Apart from that I love your 
code!

http://www.codeproject.com/Articles/12711/Google-Translator

Original issue reported on code.google.com by ne...@animenord.com on 30 Jan 2012 at 2:58

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I am also interested in this bug. I hope it will be solved soon. Using this 
library for my test application: https://github.com/IonicaBizau/text-to-speech

Thanks!

Original comment by bizauion...@gmail.com on 30 May 2013 at 10:33

GoogleCodeExporter commented 9 years ago
I created a version which solve the problem. And the translation is complete, 
but there is a failure if the character is inserted " or «. It's because 
google translate will change eg Spanish to English, the character « by ". By 
collecting all the text skips somewhere or add some of the original language. 
But what I need is going very well, and it is only with these 2 characters, if 
you're interested in the code you have no more to ask.

Thanks for your lib, I found looking for, because I was creating a method to 
perform the translation from google translate.

Original comment by jtapiat1...@gmail.com on 12 Feb 2014 at 12:23

GoogleCodeExporter commented 9 years ago
Why make him ask.... Fixed it. For anyone else who want's a full translation. 
com.gtranslate.parsing.ParseTextTranslate.java

replace the code for public void parse() with:

@Override
    public void parse() {
        appendURL();
        String result = WebUtils.source(url.toString());        
        result = result.substring(0, result.indexOf("]]"));

        String split[] = result.split("],\\[");
        StringBuilder builder = new StringBuilder();

        for(String sub : split){
            String[] subs = sub.split("\\\",\\\"");         
            if(builder.length() > 0){
                builder.append(" ");
            }
            builder.append(subs[0].replace("[", "").replace("]", "").replace("\"", "").replace(" .", ".").trim());
        }   

        Text output = textTranslate.getOutput();
        output.setText(builder.toString());
    }

Original comment by cthb...@gmail.com on 30 Apr 2014 at 9:58

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
As a workaround, you can use the java.util.StringTokenizer to translate the 
whole sentence. See the code attached for more details.

Original comment by prateekm...@gmail.com on 2 Mar 2015 at 12:05

Attachments: