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

  • Hi Agnes,

    In the 'Provider' class of your plugin, make sure that the boolean property 'SupportsMultipleResults' returns true...in case you haven't already done that.

    There is a setting in Studio (Project settings > Language Pairs > Search) that affect the number of results returned, but the default is 5 I think. Also, if there are multiple providers selected, there is a setting on that same page to limit the results to the best match.
  • Thank you, Patrick!
    The property is already set to true, and the number of results is 5 in the settings, and "Search for fuzzy matches even if exact match is found" is checked, and I tried both options for multiple providers (however, I only have one provider now, my TM plugin, and all my TMs are disabled). Nothing helps :( I only have 1 result in the results tab, even though I know that I return several results.
    Does this actually work for you?

    Thank you!
    Agnes
  • Hi Agnes,
    It sounds like you've covered all bases. None of my recent work has included multiple results, but I have done it before in testing, when it appeared to work. I don't remember if this was back with Studio 2011 or 2014. Could it have something to do with the way you are constructing the return results in the SearchSegment method? My approach would be to step through the code and check the values being passed back to Studio. I imagine you have probably already done that to some extent, but perhaps you can find if there is a bug in your code somewhere in that part of the method.

    In any case, my plan is in fact to move away from implementing translation providers altogether and instead do everything from a custom view part as part of the integration API. I just found out that you can modify the current segment in the document from a custom editor view pane, including the match score, segment confirmation status, origin, text, etc. The advantage is there would be much more control over the display in the view part than you get with the built-in translation provider interface. I will probably post back to the community with updates on this for anyone who is interested.

  • Hi Patrick,
    I'd looked at everything already, and there are several results, and only one is displayed. The same with concordance :(
    But thanks for the suggestions about the custom view, I think I'll also check that out in the future. So I'm definitely interested in your findings.
    Thanks,
    Agnes
  • Hi Patrick,
    do you know that perhaps there's a property in the SearchResults class that would determine the number of hits displayed? I might be missing something here.
    Thanks,
    Agnes
  • 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;
    }
  • I'm a bit confused now. Is this about FieldValues or about multiple results? For multiple results try this sr.Results.add(item) instead of sr.Add(item)

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

  • Hi Romulus,
    this question is about multiple results, but I didn't want to post the same thing in the other question. I thought if at least one of my problems was solved I'd be a very happy person. And now I am, as I managed to find a solution to this one :)
    I had already tried adding values in all possible ways, and nothing had worked.
    But I found what was missing: the ResourceId field from my translation units. That was all I needed.
    Thank you for all your efforts!
  • I'm glad you find a solution

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