No Term Recognition when using a Custom Terminology Provider

I'm building a custom terminology provider. I've got it to the state where I can search terms and show the search result's details in the Termbase Viewer panel.

But I'm unable to have terms in the source segment recognised as being present in the termbase.

For example, in my test project I have a source document containing only the text 'Hallo Welt'. Attached to this project is a file-based MultiTerm termbase with only the following entry:

Once the file is opened in Trados Studio the text in the source segment is recognised:

As can be seen, the text in the source segment is recognised (red line above the text) and the termbase entry is shown in the Term Recognition panel.

If I now remove that MultiTerm termbase from the project and hook up my own termbase in its place (via the custom terminology provider), I can show that 'Hello world'/'Hallo Welt' is in this termbase because I can search for it and receive the result...

The above screenshot also has the Termbase Viewer panel open to show that the result is from my terminology provider - the search result is also visible in the Termbase Search panel. But as can be seen, there's no red line in the source segment.

Here's almost the same screenshot, this time with an empty Term Recognition panel:

I know that the source segment is being searched for because it hits the expected breakpoint in my code. I also know that the search result is being returned from that method.

I've also tried the ExcelTerminology example plugin and it does exactly the same as mine - it only displays search results and doesn't indicate any hits in the source segments or the Term Recognition panel.

Can anyone explain why that search result is not shown in either the Term Recognition panel or with the addition of a red line above the source text?

  • Hi ,

    I am also working on a terminology provider and I get to the same issue as you. I have looked on the Excel Terminology but in that case the recognition is working fine. As I investigated in the code behind, I noticed that:
    1) When you are on an active segment, the Search() method is triggered.
    2) After the results are returned, then the method "public override IEntry GetEntry(int id)" is fired.
    3) The GetEntry(int id) method returns the recognized terms which are displayed in the grid and also the terms are underlined with the red line.
    In my terminology provider, only the Search() method is triggered and the "public override IEntry GetEntry(int id)" is not called anymore, so now I am now investigating what's the reason. (Probably you should also do a debug in your code and see if the "public override IEntry GetEntry(int id)" is called when you are on the Term Recognition tab and you navigate thorough segments).

    Once I will have an answer to this issue, I will let you know


    With kind regards,
    Florentina Caputa.
  • Hi Florentina,

    Yes, my terminology provider does go into public override IEntry GetEntry(int id).

  • Hi ,

    I managed to get the Term Recognition working on my side. What I have done on my side:
    1) When getting the terms in the Search results, besides the translated terms for target language, also map the source information, like:
    var termResult = new SearchResultModel
    {
    Text = termValue,
    Id = _id,
    Score = 100,
    Language = languageModel,
    Definition = definition != null ? definition.ToString() : string.Empty
    };
    termsList.Add(termResult);

    The SearchResultModel() is a custom class model which implements ISearchResults interface, and which has in plus, the Definition property (used to display the definition of the field, nearby the term result. The Definition field is optional)
    All results are added together into the same list (both source and target models) (As I saw, Studio knows how to map the terms after you create the terms entries).

    2) After doing the last changes in the code, I have recreated the Studio project, add the terminology provider and check again the Term Recognition part (which was working this time).

    I will also add a reference to the documentation which helped me to understand the Terminology Provider API: producthelp.sdl.com/.../e5bc1ec1-2649-41db-855a-1cbd82b7e20d.htm


    I hope the above steps are useful.

    With kind regards,
    Florentina Caputa
  • Hi Florentina,

    Sorry about the delay in responding.

    I've tried to follow your suggestion by adding the following code...

    var results = new List<ISearchResult>();

    foreach (var concept in concepts)
    {
        var term = concept.TermGroups.FirstOrDefault().Terms.FirstOrDefault();
        var lang = CultureInfo.GetCultureInfo(term.Language.Code);

        results.Add(new Model.Search.Term
                        {
                            Definition = text,    // 'text' is the original search term which was passed here by Trados Studio
                            Id = term.ConceptID,
                            Language = new DefinitionLanguage
                                           {
                                               Locale = lang,
                                               Name = lang.Name
                                           },
                            Score = 100,
                            Text = term.TermTranslation
                        });
    }

    return results;

    In case it isn't obvious, I've added the 'string Definition' property to each Term object being returned. It is assigned the same value which Trados Studio passed to my custom terminology provider as the sought-after term.

    My Term class now looks like this...

    public class Term : ISearchResult
    {
        public long ConceptId { get; set; }
        public string Definition { get; set; }
        public int Id { get; set; }
        public string Text { get; set; }
        public int Score { get; set; }
        public ILanguage Language { get; set; }
    }

    However, the matching text in the source segment is still not highlighted. In the screenshot below you can see that "hello world" has received a hit from searching in the termbase, and the returned term can be seen in the Termbase Viewer, but you can also see that the source segment(s) receive no highlighting.

    Screenshot of Trados Studio showing the Termbase Viewer with 'hello world' search results in different languages but no highlighting in the source segment.

    And nor does anything appear in the Term Recognition field when changing segments...

    Screenshot of Trados Studio with the Term Recognition pane open showing 'No results available' despite 'hello world' being present in the source segment.

    I know that search results are being returned when changing segments because the breakpoint is hit...

    Screenshot of code in Trados Studio with a highlighted section showing the addition of a 'Definition' property to the Term class and an arrow pointing to the 'hello world' search term.

    So... any ideas what might still be missing?



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

    You can have a look on the solution on which I am currently working from the Github: github.com/.../IATETerminologyProvider . The application is still on developing, so it will change. The Termbase Search and Term Recognition is working from this solution, so it might help you.

    With king regards,
    Florentina Lucia
  • Hi Florentina,

    I see that your implementation of ISearchResult contains two additional properties...

    string Domain { get; set; }
    string Subdomain { get; set; }

    Can you explain the role which these properties play? While I can look through your project I don't think I can run it against a project which prevents me from inspecting what each of the models actually contains.

    Must the values of these properties match with properties elsewhere?

  • HI ,

    Thanks for the tips and tricks :) As I previously mentioned, the application is still in developing so it might suffer changes/refactoring. The Domain and Subdomain properties are app related(for this the terminology on which I am working), so you don't need to use them in your application. You can personalize the ISearchResult implementation as much as you want, based on your provider needs.

    With kind regards,
    Florentina Caputa.
  • The interesting bit would be to see how you implemented IEntry.
    The initial Search() is just to establish if and which terms you can deliver (the source text you can match). What counts is the actual delivery of the terms in GetEntry(). It doesn't take your word for it: if you don't return the found IEntry it won't draw a pretty red line above the matched text let alone show search results.
  • Hi Angela,

    What counts is the actual delivery of the terms in GetEntry()

    Aha! That's it. I've finally got it working. I was paying all the attention to Search(...) but that just needs the Id property populated and everything for the UI comes from the GetEntry(...) method.

    Thank you very much.