Displaying several TM results in the editor

Hi All,


I'm developing a TM plugin, and it returns several results for a segment in the lookup. But Studio only displays one TM match in the editor, the first one. Is there a setting in Studio to change this, or do I have to set something in my results? What am I missing?

Thank you,

Agnes

Parents
  • Not sure how you've implemented this but you can have a look here. This plugin is a translation memory provider that is calling all configure MT providers and then merge the results from all of them.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • Hi Romulus,
    thank you for the code!
    I've been trying and trying and looking and looking, but to no avail. I've also made another absolutely basic plugin just to test this, and still I only have one result displayed. My settings are: several results even if a 100% match is displayed, and display matches from all providers, threshold is 70.
    Here below is the code that creates the results. I created the 2 translation units to differentiate between them (I thought perhaps that's the problem, but it seems it isn't). I have a feeling that I'm missing something very trivial and obvious here.
    If you have time, could you have a look at it? If you'd prefer trying, I can also send (upload?) the test plugin itself or the solution.)

    As you can see it here I also added a field value to the translation unit, but when I want to edit that TU, the fieldvalues are null in the parameter in UpdateTranslationUnits.

    Thank you so much,
    Agnes

    public SearchResults[] SearchTranslationUnitsMasked(SearchSettings settings, TranslationUnit[] translationUnits, bool[] mask)
    {
    SearchResults[] s = new SearchResults[translationUnits.Length];
    for (int i = 0; i < translationUnits.Length; i++)
    {
    if (mask[i])
    {
    s[i] = makeResults(translationUnits[i].SourceSegment);
    s[i].Merge(makeResults(translationUnits[i].SourceSegment), false);
    }
    else s[i] = null;
    }
    return s;
    }

    private SearchResults makeResults(Segment segment)
    {
    SortSpecification sortSpec = new SortSpecification();
    sortSpec.Add(new SortCriterium("ScoringResult", SortDirection.Descending));
    sortSpec.Add(new SortCriterium("ChangeDate", SortDirection.Descending));

    SearchResults sr = new SearchResults(sortSpec);
    TranslationUnit tu1 = new TranslationUnit(segment, segment);
    tu1.SystemFields.ChangeDate = DateTime.UtcNow;
    tu1.FieldValues = new FieldValues() { new SingleStringFieldValue("MyField", "Value") };

    TranslationUnit tu2 = new TranslationUnit(segment, segment);
    tu2.SystemFields.ChangeDate = DateTime.UtcNow;
    tu2.FieldValues = new FieldValues() { new SingleStringFieldValue("MyField", "Value") };

    SearchResult item = new SearchResult(tu1);
    item.TranslationProposal = tu1;
    item.ScoringResult = new ScoringResult();
    item.ScoringResult.BaseScore = 95;
    sr.Add(item);

    item = new SearchResult(tu2);
    item.TranslationProposal = tu2;
    item.ScoringResult = new ScoringResult();
    item.ScoringResult.BaseScore = 85;
    sr.Add(item);

    sr.SourceSegment = segment;
    return sr;
    }
Reply
  • Hi Romulus,
    thank you for the code!
    I've been trying and trying and looking and looking, but to no avail. I've also made another absolutely basic plugin just to test this, and still I only have one result displayed. My settings are: several results even if a 100% match is displayed, and display matches from all providers, threshold is 70.
    Here below is the code that creates the results. I created the 2 translation units to differentiate between them (I thought perhaps that's the problem, but it seems it isn't). I have a feeling that I'm missing something very trivial and obvious here.
    If you have time, could you have a look at it? If you'd prefer trying, I can also send (upload?) the test plugin itself or the solution.)

    As you can see it here I also added a field value to the translation unit, but when I want to edit that TU, the fieldvalues are null in the parameter in UpdateTranslationUnits.

    Thank you so much,
    Agnes

    public SearchResults[] SearchTranslationUnitsMasked(SearchSettings settings, TranslationUnit[] translationUnits, bool[] mask)
    {
    SearchResults[] s = new SearchResults[translationUnits.Length];
    for (int i = 0; i < translationUnits.Length; i++)
    {
    if (mask[i])
    {
    s[i] = makeResults(translationUnits[i].SourceSegment);
    s[i].Merge(makeResults(translationUnits[i].SourceSegment), false);
    }
    else s[i] = null;
    }
    return s;
    }

    private SearchResults makeResults(Segment segment)
    {
    SortSpecification sortSpec = new SortSpecification();
    sortSpec.Add(new SortCriterium("ScoringResult", SortDirection.Descending));
    sortSpec.Add(new SortCriterium("ChangeDate", SortDirection.Descending));

    SearchResults sr = new SearchResults(sortSpec);
    TranslationUnit tu1 = new TranslationUnit(segment, segment);
    tu1.SystemFields.ChangeDate = DateTime.UtcNow;
    tu1.FieldValues = new FieldValues() { new SingleStringFieldValue("MyField", "Value") };

    TranslationUnit tu2 = new TranslationUnit(segment, segment);
    tu2.SystemFields.ChangeDate = DateTime.UtcNow;
    tu2.FieldValues = new FieldValues() { new SingleStringFieldValue("MyField", "Value") };

    SearchResult item = new SearchResult(tu1);
    item.TranslationProposal = tu1;
    item.ScoringResult = new ScoringResult();
    item.ScoringResult.BaseScore = 95;
    sr.Add(item);

    item = new SearchResult(tu2);
    item.TranslationProposal = tu2;
    item.ScoringResult = new ScoringResult();
    item.ScoringResult.BaseScore = 85;
    sr.Add(item);

    sr.SourceSegment = segment;
    return sr;
    }
Children