Problem with the SDL Trados Studio 2019 SR1 API development

Hello, I have an API development issue with SDL Trados Studio 2019 SR2 (15.2.0.1041).

I get the error message "One or more errors accored" at the following program line:

SearchResults results = langDirection.SearchText(sdlSearchSettings, "Telefonliste");

I get the same error message if I replace the above program line with the following program line.

SearchResults results = langDirection.SearchText(new Sdl.LanguagePlatform.TranslationMemory.SearchSettings(), "Telefonliste");

My work environment consists of the following systems:

- SDL Trados Studio 2019 SR2 (15.2.0.1041)
- 2 SDL Trados GroupShare 2017 SR1 test systems: SDL Trados GroupShare 2017 SR1 CU8 and SDL Trados GroupShare 2017 SR1 CU9 Refresh.
- MS Visual Studio 2017

Thanks a lot in advance for your support.

Best regards,
Christian Albrecht

My test program code:


using System;
using System.Collections.Generic;
using log4net;
using Sdl.LanguagePlatform.TranslationMemoryApi;
using Sdl.LanguagePlatform.TranslationMemory;
using Sdl.LanguagePlatform.Core.Tokenization;
using Sdl.LanguagePlatform.Core;


namespace ConsoleApp1
{
    class Program
    {
        private static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        
        private static TranslationProviderServer tmServer;

        static void Main(string[] args)
        {
            Connect("http://<server>:<Port>", "<Username>", "<Password>", "/<TM>");
        }

        private static void Connect(string serverUri, string userName, string password, string translationMemory)
        {
            List<string> tmList = new List<string>();
            string hitList;

            try
            {
                tmServer = new TranslationProviderServer(GetUri(serverUri), false, userName, password);

                SearchSettings sdlSearchSettings = new SearchSettings();

                ServerBasedTranslationMemory tm = tmServer.GetTranslationMemory(translationMemory, TranslationMemoryProperties.None);

                ServerBasedTranslationMemoryLanguageDirection langDirection = tm.LanguageDirections.GetLanguageDirection("de-DE", "en-GB");
                sdlSearchSettings.ComputeTranslationProposal = true;
                sdlSearchSettings.Mode = SearchMode.ConcordanceSearch;
                sdlSearchSettings.Mode = SearchMode.NormalSearch;
                sdlSearchSettings.MinScore = 75;
                sdlSearchSettings.MaxResults = 5;
                sdlSearchSettings.FindPenalty(PenaltyType.FilterPenalty);
                sdlSearchSettings.CheckMatchingSublanguages = false;
                
                SearchResults results = langDirection.SearchText(sdlSearchSettings, "Telefonliste");
                
                
                 //Initializes a new instance with default values. The default values are:
                //ComputeTranslationProposal = false
                //IsDocumentSearch = false
                //Mode = SearchMode.NormalSearch
                //MinScore = 70
                //MaxResults = 10
                //CheckMatchingSublanguages = false

                //SearchResults results = langDirection.SearchText(new Sdl.LanguagePlatform.TranslationMemory.SearchSettings(), "Telefonliste");

        hitList = "Search result: " + "Test" + "\n\n";
                hitList += "Number of hits found: " + results.Count.ToString() + "\n";
                foreach (SearchResult result in results)
                {
                    hitList += "\n" + "Source segment: " + result.MemoryTranslationUnit.SourceSegment.ToPlain() + "\n";
                    hitList += "Target segment: " + result.MemoryTranslationUnit.TargetSegment.ToPlain() + "\n";
                    hitList += "Created on: " + result.MemoryTranslationUnit.SystemFields.CreationDate.ToString() + "\n";
                    hitList += "Origin: " + result.MemoryTranslationUnit.Origin.ToString() + "\n";
                    hitList += "Match value: " + result.ScoringResult.Match.ToString() + "\n";
                    hitList += "Fields:" + "\n";
                    foreach (FieldValue field in result.MemoryTranslationUnit.FieldValues)
                    {
                        hitList += field.Name + ": " + field.ToString() + "\n";
                    }
                }

            }
            catch (Exception ex)
            {
                log.Error("Error: " + ex.Message);
            }

        }

        private static Uri GetUri(string uri)
        {
            string address = uri;
            return new Uri(address);
        }
    }
}

Parents Reply Children
No Data