Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement TranslateArray service #5

Closed
boatmeme opened this issue May 28, 2011 · 7 comments
Closed

Implement TranslateArray service #5

boatmeme opened this issue May 28, 2011 · 7 comments
Assignees
Milestone

Comments

@boatmeme
Copy link
Owner

The bulk, array-based version of Translate

documentation

@ghost ghost assigned boatmeme May 28, 2011
@boatmeme boatmeme reopened this May 29, 2011
@moonlightshadow
Copy link

looking forward to this feature,anything i can do?

@boatmeme
Copy link
Owner Author

boatmeme commented Jun 2, 2011

Hi!

Absolutely, I was hoping for some help going forward.

I had intended to include this in the 0.3 Release, but needed some more time to think about the implementation after I discovered how the TranslateArray service worked. ..

Looking at that documentation link in the original issue, from the description of the texts parameter:

  • An array containing the texts for translation. All strings should be of the same language.

Is this the behavior you would expect from a TranslateArray service? My own assumptions were that you could specify a to/from language pair PER translation in the array, but it does not seem to work that way, even when using the AUTO_DETECT.

It would of course be possible for us to overload the Translate.execute() method to perform such functionality (albeit in an entirely manual, multiple-call kind of way) Something like this, maybe...

// This method actually calls the TranslateArray service, making a single call and passing an array to the service
public static String[] execute(final String[] texts, final Language fromLang, final Language toLang) throws Exception

// This method calls the Translate service multiple times, once for each set of text/fromLang/toLang in the array
public static String[] execute(final String[] texts, final Language[] fromLangs, final Language[] toLangs) throws Exception

I think that the first method is OK as long as it is clear that every text in String[] must be of the same language. It is also correct in that
it truly exposes the functionality of the MS TranslateArray, regardless of how I think it should work.

The second method is probably a bad idea as it just confuses the issue and provides functionality that a client could easily build. Indeed, it would probably be easier for a client just to make multiple calls to execute() than to build 3 different arrays and pass them in.

I'd like to hear your thoughts on the issue and your expectations for this functionality.

Feel free to fork away on the code and issue pull requests. I'm a GitHub noob, but I'm anxious to experience some of the 'social coding' aspects.

-jonathan

@moonlightshadow
Copy link

hi,
An array containing the texts for translation. All strings should be of the same language.
YES ,it is exactly the behavior i would expect from this,cause i would send multiple request in order to execute translation to different destination languages, meanwhile the second way is easy to make any mistakes ,also hard to find them. for me the reason why i would use this method comes from two considerations:1.by doing this i can save requests in order not to reach the limits for one minite(although it has been removed).2.making batch translate so as to saving time,the data i want to be translated one day is million level.
btw,since the api has a hourly or daily limit on characters been translated,have you consider providing a Translate Cllient Pool to improve the total translate character amount one user can make?

-Weilie Chen

@boatmeme
Copy link
Owner Author

boatmeme commented Jun 2, 2011

I agree with you about the behavior of TranslateArray. Thanks for the discussion, it really cleared my head on the issue.

I can likely get that functionality in for 0.4 sometime this weekend or early next week. Otherwise, if you were motivated enough to take it on yourself, you're more than welcome to do so. You could take a look at the way DetectArray service was implemented in the Detect class and try to follow that pattern.


What do you mean by Translate Client Pool?

Do you mean a pool of clients that have different ApiKeys associated to them? As I understand it, Microsoft tracks usage not only by ApiKey, but by IP Address as well, so I'm not sure how this feature would alleviate the rate limits.

...or are you thinking of a cache, so that we do not repeat calls to the API for identical translation requests? If so, that is something I've considered and in fact something I implemented for the grails-translate plugin that uses this library. My gut feeling is to let the library mature without bulking up too much before pulling such features in.

@boatmeme
Copy link
Owner Author

boatmeme commented Jun 2, 2011

Weilie -

Forget about forking the code, I was able to implement the TranslateArray service this morning.

I will merge it over to the master branch and release a SNAPSHOT of the 0.4 release that you may use. Are you using Maven for your projects or are you downloading the JARs and including them in your /lib?

@moonlightshadow
Copy link

thanks for your great job!

@boatmeme
Copy link
Owner Author

boatmeme commented Jun 3, 2011

You're welcome, I appreciate the feedback about TranslateArray.

I uploaded the 0.4 snapshot jar with the changes. Or, if you're using Maven, just add this to your POM.xml:

<dependency>
    <groupId>com.memetix</groupId>
    <artifactId>microsoft-translator-java-api</artifactId>
    <version>0.4-SNAPSHOT</version>
    <type>jar</type>
</dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants