Answer the question
In order to leave comments, you need to log in
How to solve the problem with (probably) memory overflow?
Hello.
I have some array of strings (consisting of English words) obtained as follows:
string stringFromBook = "...Здесь разные англоязычные слова (разделенные пробелами) из некоторой книги...";
string[] words = stringFromBook.Split(' '); //Превращаю строку в массив
static string GetTranscriptionFromYandexTranslator(string englishWord) {...} //Тело метода приведено ниже
Console.WriteLine(transcripAndWord);
string stringFromBook = "...Здесь разные англоязычные слова (разделенные пробелами) из некоторой книги...";
class Program
{
//Метод получения транскрипции через API Яндекс-переводчика
static string GetTranscriptionFromYandexTranslator(string englishWord)
{
string transcription;
var translateUrl = "https://dictionary.yandex.net/dicservice.json/lookup?ui=ru&text=" + englishWord + "&lang=en-ru&flags=23";
using (var wc = new WebClient())
{
wc.Encoding = Encoding.UTF8;
var resultHtml = wc.DownloadString(translateUrl);
dynamic trsJson = JObject.Parse(resultHtml);
var trs = trsJson.def[0].ts;
transcription = trs;
}
return transcription;
}
static void Main(string[] args)
{
string stringFromBook = "...Здесь разные англоязычные слова (разделенные пробелами) из некоторой книги...";
string[] words = stringFromBook.Split(' ');
string transcripAndWord, transcription;
for (int i = 0; i < words.Length; i++)
{
transcription = GetTranscriptionFromYandexTranslator(words[i]);
transcripAndWord = words[i] + " [" + transcription + "]";
Console.WriteLine(transcripAndWord);
}
Console.ReadLine();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question