示例#1
0
        private SearchResult CreateSearchResult(Segment segment, TartuNLPTagPlacer tagPlacer, string translation)
        {
            var targetSegment = tagPlacer.GetTaggedSegment(translation);

            // handle cases where input and output tags did not match
            if (targetSegment == null)
            {
                var sourceStrings = new List <string> {
                    segment.ToPlain()
                };
                translation = SearchInServer(sourceStrings)[0];

                targetSegment = new Segment(_languageDirection.TargetCulture);
                targetSegment.Add(translation);
            }

            var translationUnit = new TranslationUnit
            {
                SourceSegment = segment.Duplicate(),
                TargetSegment = targetSegment
            };

            translationUnit.ResourceId = new PersistentObjectToken(translationUnit.GetHashCode(), Guid.Empty);
            translationUnit.Origin     = TranslationUnitOrigin.MachineTranslation;

            var searchResult = new SearchResult(translationUnit)
            {
                ScoringResult = new ScoringResult()
            };

            return(searchResult);
        }
        private SearchResult CreateSearchResult(Segment segment, TartuNLPTagPlacer tagPlacer, string translation)
        {
            var targetSegment = tagPlacer.GetTaggedSegment(translation);

            var translationUnit = new TranslationUnit
            {
                SourceSegment = segment.Duplicate(),
                TargetSegment = targetSegment
            };

            translationUnit.ResourceId = new PersistentObjectToken(translationUnit.GetHashCode(), Guid.Empty);
            translationUnit.Origin     = TranslationUnitOrigin.MachineTranslation;

            var searchResult = new SearchResult(translationUnit)
            {
                ScoringResult = new ScoringResult()
            };

            return(searchResult);
        }