Custom batch pre-translationfuction skipping segment or missing result

When I develop a plugin use the Batch task API ,I custom a batch pre-translation function,but when I send the source text to translation engine to ask for the result ,The result is not inserted into the corresponding segment or the result is missing.  I want to know the reason.

Parents
  • You need to set this value:

    Trados Studio options menu with Translation Memory and Automated Translation settings, highlighting 'Concordance search fuzzy threshold' field with a red arrow pointing to it.



    Generated Image Alt-Text
    [edited by: Trados AI at 1:22 PM (GMT 0) on 5 Mar 2024]
  • Deer Paul

    The code is as follow:WIll you please give me some advice about the code? Thanks. 

    public void TranslateBatch2()
    {
    if (this.segPairs_in_batch.Count <= 0)
    return;
    Itranlate tranlate = GetTranlate();
    string[] txttobetranslated = new string[this.segPairs_in_batch.Count];
    string[] splitArr = new string[this.segPairs_in_batch.Count];
    string translateStr = "";
    string spaceSplit = "";//分割符
    switch (this.__setings.useOperType)
    {
    case "1"://爱词霸
    spaceSplit = "555";
    break;
    case "2"://百度
    spaceSplit = "{{8}}";
    break;
    case "3"://谷歌
    spaceSplit = "{{8}}";
    break;
    case "4"://搜狗
    spaceSplit = "AKA8AKA";
    break;
    case "5"://腾讯
    spaceSplit = "{{8}}";
    break;
    case "6"://有道
    spaceSplit = "{}";
    break;
    }
    int total = 0;
    TagProcessor[] tagProcessorArray = new TagProcessor[this.segPairs_in_batch.Count];
    try
    {
    for (int index = 0; index < this.segPairs_in_batch.Count; index++)
    {
    var a = new TagProcessor(new Segment(this.SourceLang.CultureInfo), true, null, this.SourceLang.UseBlankAsWordSeparator, this.SourceLang.CultureInfo, this.TargetLang.UseBlankAsWordSeparator);
    tagProcessorArray[index] = a;

    var txt2 = BatchTranslatorProcessor.GetPlainTextFromSegment(this.segPairs_in_batch[index].Source);
    var txt1 = tagProcessorArray[index].ReplaceSrcTextWithTargetTextDirectly(txt2);
    var txt0 = tagProcessorArray[index].ReplaceSourceTextwithTags(txt1);
    txttobetranslated[index] = txt0;
    total += a.GetWordCount(txt0, false);

Reply
  • Deer Paul

    The code is as follow:WIll you please give me some advice about the code? Thanks. 

    public void TranslateBatch2()
    {
    if (this.segPairs_in_batch.Count <= 0)
    return;
    Itranlate tranlate = GetTranlate();
    string[] txttobetranslated = new string[this.segPairs_in_batch.Count];
    string[] splitArr = new string[this.segPairs_in_batch.Count];
    string translateStr = "";
    string spaceSplit = "";//分割符
    switch (this.__setings.useOperType)
    {
    case "1"://爱词霸
    spaceSplit = "555";
    break;
    case "2"://百度
    spaceSplit = "{{8}}";
    break;
    case "3"://谷歌
    spaceSplit = "{{8}}";
    break;
    case "4"://搜狗
    spaceSplit = "AKA8AKA";
    break;
    case "5"://腾讯
    spaceSplit = "{{8}}";
    break;
    case "6"://有道
    spaceSplit = "{}";
    break;
    }
    int total = 0;
    TagProcessor[] tagProcessorArray = new TagProcessor[this.segPairs_in_batch.Count];
    try
    {
    for (int index = 0; index < this.segPairs_in_batch.Count; index++)
    {
    var a = new TagProcessor(new Segment(this.SourceLang.CultureInfo), true, null, this.SourceLang.UseBlankAsWordSeparator, this.SourceLang.CultureInfo, this.TargetLang.UseBlankAsWordSeparator);
    tagProcessorArray[index] = a;

    var txt2 = BatchTranslatorProcessor.GetPlainTextFromSegment(this.segPairs_in_batch[index].Source);
    var txt1 = tagProcessorArray[index].ReplaceSrcTextWithTargetTextDirectly(txt2);
    var txt0 = tagProcessorArray[index].ReplaceSourceTextwithTags(txt1);
    txttobetranslated[index] = txt0;
    total += a.GetWordCount(txt0, false);

Children
No Data