Ejemplo n.º 1
0
        public override machineTranslationResult getTargetLang(string sourceText)
        {
            urlAPI.Mymemory url = new urlAPI.Mymemory();
            client.requestAPI(String.Format(url.urlTranslatorMymemory, sourceText, source, target));
            var contentJson = client.getContentFromResopne();
            var content     = JsonConvert.DeserializeObject <Mymemory>(contentJson);
            machineTranslationResult Result = new machineTranslationResult();

            if (sourceText.Length >= 500)
            {
                Result.fail     = true;
                Result.failText = fail;
            }
            else
            {
                if (content != null)
                {
                    Result.src   = sourceText;
                    Result.tag   = content.responseData.translatedText;
                    Result.type  = name;
                    Result.fail  = false;
                    Result.score = float.Parse(content.responseData.match) * 100;
                }
                else
                {
                    Result.fail     = true;
                    Result.failText = fail;
                }
            }
            return(Result);
        }
Ejemplo n.º 2
0
        public override string getTargetLang(string sourceText)
        {
            urlAPI.Mymemory url = new urlAPI.Mymemory();
            client.requestAPI(String.Format(url.urlTranslatorMymemory, sourceText, source, target));
            var    contentJson = client.getContentFromResopne();
            var    content     = JsonConvert.DeserializeObject <Mymemory>(contentJson);
            string targetText  = null;

            if (content != null)
            {
                targetText = content.responseData.translatedText + "\n" + name;
            }
            else
            {
                targetText = fail;
            }
            return(targetText);
        }