本文整理汇总了C#中Segment.Duplicate方法的典型用法代码示例。如果您正苦于以下问题:C# Segment.Duplicate方法的具体用法?C# Segment.Duplicate怎么用?C# Segment.Duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment.Duplicate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSearchResult
private SearchResult CreateSearchResult(Segment searchSegment, Segment translation,
string sourceSegment)
{
#region "TranslationUnit"
TranslationUnit tu = new TranslationUnit();
tu.SourceSegment = searchSegment.Duplicate();//this makes the original source segment, with tags, appear in the search window
tu.TargetSegment = translation;
#endregion
tu.ResourceId = new PersistentObjectToken(tu.GetHashCode(), Guid.Empty);
int score = 0; //score to 0...change if needed to support scoring
tu.Origin = TranslationUnitOrigin.MachineTranslation;
SearchResult searchResult = new SearchResult(tu);
searchResult.ScoringResult = new ScoringResult();
searchResult.ScoringResult.BaseScore = score;
tu.ConfirmationLevel = ConfirmationLevel.Draft;
return searchResult;
}
开发者ID:patrickporter,项目名称:MT-Enhanced-Trados-Plugin,代码行数:20,代码来源:MtTranslationProviderLanguageDirection.cs
示例2: SearchSegment
public SearchResults SearchSegment(SearchSettings settings, Segment segment)
{
//FUTURE: consider making GT and MT lookup classes static utility classes
Segment translation = new Segment(_languageDirection.TargetCulture);//this will be the target segment
#region "SearchResultsObject"
SearchResults results = new SearchResults();
results.SourceSegment = segment.Duplicate();
#endregion
#region "Confirmation Level"
if (!_options.ResendDrafts && inputTu.ConfirmationLevel != ConfirmationLevel.Unspecified) //i.e. if it's status is other than untranslated
{ //don't do the lookup, b/c we don't need to pay google to translate text already translated if we edit a segment
translation.Add(PluginResources.TranslationLookupDraftNotResentMessage);
//later get these strings from resource file
results.Add(CreateSearchResult(segment, translation, segment.ToString()));
return results;
}
#endregion
// Look up the currently selected segment in the collection (normal segment lookup).
#region "SegmentLookup"
string sourceLang = SourceLanguage.ToString();
string targetLang = TargetLanguage.ToString();
string translatedText = "";
//a new seg avoids modifying the current segment object
Segment newseg = segment.Duplicate();
//do preedit if checked
bool sendTextOnly = _options.SendPlainTextOnly || !newseg.HasTags;
if (!sendTextOnly)
{
//do preedit with tagged segment
if (_options.UsePreEdit)
{
if (preLookupSegmentEditor == null) preLookupSegmentEditor = new SegmentEditor(_options.PreLookupFilename);
newseg = getEditedSegment(preLookupSegmentEditor, newseg);
}
//return our tagged target segment
MtTranslationProviderTagPlacer tagplacer = new MtTranslationProviderTagPlacer(newseg);
////tagplacer is constructed and gives us back a properly marked up source string for google
if (_options.SelectedProvider == MtTranslationOptions.ProviderType.GoogleTranslate)
{
translatedText = LookupGT(tagplacer.PreparedSourceText, _options, "html");
}
else if (_options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator)
{
translatedText = LookupMST(tagplacer.PreparedSourceText, _options, "text/html");
}
//now we send the output back to tagplacer for our properly tagged segment
translation = tagplacer.GetTaggedSegment(translatedText).Duplicate();
//now do post-edit if that option is checked
if (_options.UsePostEdit)
{
if (postLookupSegmentEditor == null) postLookupSegmentEditor = new SegmentEditor(_options.PostLookupFilename);
translation = getEditedSegment(postLookupSegmentEditor, translation);
}
}
else //only send plain text
{
string sourcetext = newseg.ToPlain();
//do preedit with string
if (_options.UsePreEdit)
{
if (preLookupSegmentEditor == null) preLookupSegmentEditor = new SegmentEditor(_options.PreLookupFilename);
sourcetext = getEditedString(preLookupSegmentEditor, sourcetext);
//change our source segment so it gets sent back with modified text to show in translation results window that it was changed before sending
newseg.Clear();
newseg.Add(sourcetext);
}
//now do lookup
if (_options.SelectedProvider == MtTranslationOptions.ProviderType.GoogleTranslate)
{
translatedText = LookupGT(sourcetext, _options, "html"); //plain??
}
else if (_options.SelectedProvider == MtTranslationOptions.ProviderType.MicrosoftTranslator)
{
translatedText = LookupMST(sourcetext, _options, "text/plain");
}
//now do post-edit if that option is checked
if (_options.UsePostEdit)
{
if (postLookupSegmentEditor == null) postLookupSegmentEditor = new SegmentEditor(_options.PostLookupFilename);
translatedText = getEditedString(postLookupSegmentEditor, translatedText);
}
translation.Add(translatedText);
}
results.Add(CreateSearchResult(newseg, translation, newseg.ToPlain()));
#endregion
#region "Close"
return results;
#endregion
//.........这里部分代码省略.........
开发者ID:patrickporter,项目名称:MT-Enhanced-Trados-Plugin,代码行数:101,代码来源:MtTranslationProviderLanguageDirection.cs