|
I made a little translation loop, which starts and ends at english (for a small reddit bot; my first one, btw), but somehow I don't get the complete input text translated. If I enter a couple of words, the majority of them will get replaced with ",,," of varying lenght. This doesn't happen all the time, but I guess ~1/3 of the text gets lost and replaced with a couple of commas.
Oh, sometimes it also translates correctly, but still adds a bunch of commas. Does anybody have an idea what went wrong?
|
|
|
|
|
Sorry for the late reponse - was out of town. Will look into it and get back to you soon.
/ravi
|
|
|
|
|
Hello,
first of all thank you for sharing this with other people. I have the same problem as initially posted in this thread.
If I translate simple text from English to German like:
"Hello, how are you? I am fine, thank you."
I get:
"Hallo, wie geht es Ihnen? ,,,0, I am fine, thank you."
First sentence ends with ",,,0," and this is over of the translation. Thank you for your help.
Regards Martin
|
|
|
|
|
Thanks, Martin. Will look into it as soon as I can.
/ravi
|
|
|
|
|
changed translator.cs to fix this.
starting at line 115
string[] phrases = text.Split (new[] { '\"' }, StringSplitOptions.RemoveEmptyEntries);
for (int i=0; (i < phrases.Count()-1); i += 2) {
if (phrases[i].StartsWith(",,"))
{
i--;
continue;
}
translation += phrases[i] + " ";
}
modified 6-Aug-15 6:55am.
|
|
|
|
|
Thanks! Will test this fix.
/ravi
|
|
|
|
|
Article updated - thank you for the fix!
/ravi
|
|
|
|
|
|
|
Hi Ravi,
This project is working fine in windows application. Would it be possible to make it work with web application? I tried it but response is not coming while downloading the file. Could you please help me on this?
|
|
|
|
|
I don't see why it wouldn't work in a web app. Perhaps you're making too many frequent calls to the service? That could cause Google to block your IP for a period of time.
/ravi
|
|
|
|
|
Hi Ravi,
It's working now. Blocking part was the proxy settings.
Thanks for this valuable article.
|
|
|
|
|
/ravi
|
|
|
|
|
Thanks a lot for the google translation problem!!!!
|
|
|
|
|
You're welcome. Enjoy!
/ravi
|
|
|
|
|
I'm the user Member 11644842 , who has lost his password xD
Thanks to fix the problem.
|
|
|
|
|
My pleasure! Glad you find the class useful!
/ravi
|
|
|
|
|
Nice article. Keep it up Thx.
|
|
|
|
|
|
|
|
try to translate one word from English to French (it can be any languages) - e.g. sparrow
You will receive this:
[[[ , ],[,,, ]],[[ ,[ , , ],[[ ,[ ],,0.45783335, ],[ ,[ ],,0.0033880526, ],[ ,[ ],,0.0024787523, ]], ,1]], ,,,[[ ,1,[[ ,1000,true,false],[ ,0,true,false],[ ,0,true,false],[ ,0,true,false],[ ,0,true,false]],[[0,7]], ,0,1]],0.02046049,,[[ ],,[0.02046049]],,,[[ ,[[[ , ], sparrow noun a small finchlike Old World bird related to the weaverbirds, typically with brown and gray plumage. m_en_us1292816.001 With a beat of her tiny brown wings, the sparrow was on her way. any of a number of birds that resemble true sparrows in size or color. m_en_us1292816.002 sparrow I saw one bird, a tiny \u003cb\u003esparrow\u003c/b\u003e darting through the gnarled pine limbs. m_en_us1292816.001 With a beat of her tiny brown wings, the \u003cb\u003esparrow\u003c/b\u003e was on her way. m_en_us1292816.001 It was a light gray and it had a large black beak, more like a hawk's than a \u003cb\u003esparrow\u003c/b\u003e 's. m_en_us1292816.001 An injured \u003cb\u003esparrow\u003c/b\u003e or a bird dressed for a dining table distresses her as much as war among nations and nuclear experiments do. m_en_us1292816.001 Everything from the modest \u003cb\u003esparrow\u003c/b\u003e to the extravagant scarlet macaw came to perch and settle around her. m_en_us1292816.001 The branches serve as a handy perch for the \u003cb\u003esparrows\u003c/b\u003e and mourning doves that frequent my city bird feeder. m_en_us1292816.001 Crows and \u003cb\u003esparrows\u003c/b\u003e have been known to attack innocent passers-by who happen to stroll near their nests. m_en_us1292816.001 Smaller birds such as pigeons, thrushes, jackdaws, robins and \u003cb\u003esparrows\u003c/b\u003e would also have been seen on a regular basis. m_en_us1292816.001 He fed \u003cb\u003esparrows\u003c/b\u003e and grosbeaks on a seed tray mounted on a pole to be visible from his windows. m_en_us1292816.001 While we don't have tall trees, our neighbors do, and the firs and oaks that surround our property drop acorns and provide homes for jays, woodpeckers, robins and \u003cb\u003esparrows\u003c/b\u003e. m_en_us1292816.001 Growing up, I was fascinated by birds and my mother encouraged this by letting me feed \u003cb\u003esparrows\u003c/b\u003e on the fire-escape outside our window. m_en_us1292816.001 All wild birds (except pigeons, English \u003cb\u003esparrows\u003c/b\u003e and starlings) are protected by federal and state laws, so it's illegal to trap, kill or poison them. m_en_us1292816.001 Game birds, mockingbirds, robins, and \u003cb\u003esparrows\u003c/b\u003e enjoy the juicy, sticky red fruits. m_en_us1292816.001 Some landscapes these days have been reduced to nothing but dandelions and fire ants, knapweed and thistle, where the only remaining wildlife are \u003cb\u003esparrows\u003c/b\u003e, squirrels, and starlings. m_en_us1292816.001 One sparrow box can house up to 36 baby \u003cb\u003esparrows\u003c/b\u003e in a year. m_en_us1292816.001 Stop \u003cb\u003esparrows\u003c/b\u003e and finches from shredding crocus blossoms by placing foil pinwheels - the kind sold for children's Easter baskets - every few feet among the flowers. m_en_us1292816.001 Most folks start with a feeder or two and quickly find themselves engrossed with the resident \u003cb\u003esparrows\u003c/b\u003e, finches, and woodpeckers that eagerly accept the offerings. m_en_us1292816.001 A couple of \u003cb\u003esparrows\u003c/b\u003e who had been peacefully resting on the grey rocks abruptly flew off. m_en_us1292816.001 Budgies, finches, \u003cb\u003esparrows\u003c/b\u003e and canaries are only a few of the more than one hundred kinds of birds people keep in their apartments. m_en_us1292816.001 There is nothing to see except blackbirds and \u003cb\u003esparrows\u003c/b\u003e; nothing to hear except the noise of butterflies' wings. m_en_us1292816.001 sparrow-hawk sparrow hawk
while if your input two same words - sparrow sparrow - you will receive proper answer:
moineau moineau
Mark Doubson
|
|
|
|
|
Thanks. That seems like a lot more information than we'd like to receive.
/ravi
|
|
|
|
|
You can try use
string.Format(",\"{0}\"", Translator.LanguageEnumToIdentifier(sourceLanguage))
instead of
string.Format(",,\"{0}\"", Translator.LanguageEnumToIdentifier(sourceLanguage))
result will be more reasonable:
moineau ,,,, noun passereaux moineau ,,0.45783335, passereaux ,,0.0033880526, pierrot ,,0.0024787523, sparrow
Nothing wrong from Google side - you just need to improve you parser
|
|
|
|
|
Not quite, because I think that affects other cases. Anyway, I have a fix and will be releasing it shortly.
Thanks,
/ravi
|
|
|
|
|