コード例 #1
0
        public void translate(string sourceText)
        {
            results.Clear();
            foreach (machineTranslationBase machine in listMachine)
            {
                if (machine.isActive)
                {
                    ////string text = machine.getTargetLang(sourceText);
                    machineTranslationResult result = new machineTranslationResult();
                    result = machine.getTargetLang(sourceText);
                    if (result.fail)
                    {
                        textTranslation += result.failText + "\n";
                    }
                    else
                    {
                        textTranslation += result.tag + "\n" + result.type + "\n";
                        results.Add(result);
                    }
                    //if (result.fail)
                    //{

                    //}
                    //textTranslation += result.tag + "\n";
                    //Console.WriteLine(sourceText);
                    //Console.WriteLine(machine.source + "::" + machine.target);
                }
            }
            rtbTranslated.Text = textTranslation;
        }
コード例 #2
0
        public List <machineTranslationResult> getTranslationAllOpenNMT(List <Segment> segments)
        {
            List <machineTranslationResult> results = new List <machineTranslationResult>();
            machineTranslationBase          machine = getMachineOpenNMT();

            try
            {
                foreach (Segment segment in segments)
                {
                    machineTranslationResult resultMymemory = new machineTranslationResult();
                    string sourceText = segment.getTMSource();
                    resultMymemory = machine.getTargetLang(sourceText);
                    if (resultMymemory.fail)
                    {
                        break;
                    }
                    else
                    {
                        results.Add(resultMymemory);
                    }
                }
            }
            catch (Exception ex)
            {
                results = null;
            }

            return(results);
        }