How to use Google Translate in Matlab?

I am writing a program to list all the unique words in a movie subtitle file using Matlab. Now I have a unique list of words that I want to translate into my language and find out the meaning before watching the movie.

Does anyone know how I can use Google Translate in Matlab to complete my script? Is there any web service or how and how can I use it in matlab?

Thanks,


Appendix 1: I found this code useful:

%build url and send to google
url = 'http://ajax.googleapis.com/ajax/services/language/translate';
page = urlread(url, 'get', {'v', '1.0','q', inputString,'langpair', [sourceLanguage '|' destLanguage]});

but I don’t know why it returns an error every time I run it (for example, 403or 400). I know that my internet connection is ok during testing.

+6
source share
1

( ), , . :

langCodes = urlread('http://www.transltr.org/api/getlanguagesfortranslate'); % find your language code

textToTranslate = 'rabbit'; %change

langCodeOfOrigText ='en';
langCodeOfTranslation ='es';

translateURL = 'http://www.transltr.org/api/translate';
translateResults = urlread(translateURL, 'get', {'text',textToTranslate,'to',langCodeOfTranslation,'from',langCodeOfOrigText});

translationText . , , Google json matlab struct parser.

+2

Source: https://habr.com/ru/post/1017381/


All Articles