Class AbstractMachineTranslationProviderLanguageDirection
Implements an abstract base class for machine translation providers, and provides overridable default implementations for the most common properties and methods of ITranslationProviderLanguageDirection.
Inherited Members
Namespace: Sdl.LanguagePlatform.TranslationMemoryApi
Assembly: Sdl.LanguagePlatform.TranslationMemoryApi.dll
Syntax
public abstract class AbstractMachineTranslationProviderLanguageDirection : ISubsegmentTranslationMemoryLanguageDirection, ITranslationProviderLanguageDirection
Constructors
AbstractMachineTranslationProviderLanguageDirection(AbstractMachineTranslationProvider, LanguagePair)
Constructor.
Declaration
protected AbstractMachineTranslationProviderLanguageDirection(AbstractMachineTranslationProvider translationProvider, LanguagePair languageDirection)
Parameters
| Type | Name | Description |
|---|---|---|
| AbstractMachineTranslationProvider | translationProvider | The machine translation provider to which this language direction belongs. |
| LanguagePair | languageDirection | The language direction. |
Properties
LanguageDirection
Gets the current language direction of this instance.
Declaration
public LanguagePair LanguageDirection { get; }
Property Value
| Type | Description |
|---|---|
| LanguagePair |
SourceLanguage
Gets the source language.
Declaration
public CultureCode SourceLanguage { get; }
Property Value
| Type | Description |
|---|---|
| CultureCode |
SourceLanguageCode
Gets the source language code.
Declaration
public string SourceLanguageCode { get; }
Property Value
| Type | Description |
|---|---|
| string |
TargetLanguage
Gets the target language.
Declaration
public CultureCode TargetLanguage { get; }
Property Value
| Type | Description |
|---|---|
| CultureCode |
TargetLanguageCode
Gets the target language code.
Declaration
public string TargetLanguageCode { get; }
Property Value
| Type | Description |
|---|---|
| string |
TranslationProvider
The translation provider to which this language direction belongs.
Declaration
public ITranslationProvider TranslationProvider { get; }
Property Value
| Type | Description |
|---|---|
| ITranslationProvider |
Methods
AddOrUpdateTranslationUnitsMasked(TranslationUnit[], int[], ImportSettings, bool[])
See AddOrUpdateTranslationUnitsMasked(TranslationUnit[], int[], ImportSettings, bool[]). The default implementation
simply returns null.
Declaration
public virtual ImportResult[] AddOrUpdateTranslationUnitsMasked(TranslationUnit[] translationUnits, int[] previousTranslationHashes, ImportSettings settings, bool[] mask)
Parameters
| Type | Name | Description |
|---|---|---|
| TranslationUnit[] | translationUnits | |
| int[] | previousTranslationHashes | |
| ImportSettings | settings | |
| bool[] | mask |
Returns
| Type | Description |
|---|---|
| ImportResult[] |
AddTranslationUnitsMasked(TranslationUnit[], ImportSettings, bool[])
See AddTranslationUnitsMasked(TranslationUnit[], ImportSettings, bool[]). The default implementation
simply returns null.
Declaration
public virtual ImportResult[] AddTranslationUnitsMasked(TranslationUnit[] translationUnits, ImportSettings settings, bool[] mask)
Parameters
| Type | Name | Description |
|---|---|---|
| TranslationUnit[] | translationUnits | |
| ImportSettings | settings | |
| bool[] | mask |
Returns
| Type | Description |
|---|---|
| ImportResult[] |
CheckSettings(SearchSettings)
Verifies that the search settings are correct, and throws an exception if not. The
default implementation will check on null, and whether the search mode
is consistent with an MT provider.
Declaration
protected virtual void CheckSettings(SearchSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings |
CreateSearchResult(Segment, Segment)
Creates a search result from a pair of source and target language segments.
Declaration
protected virtual SearchResult CreateSearchResult(Segment searchSegment, Segment translation)
Parameters
| Type | Name | Description |
|---|---|---|
| Segment | searchSegment | The search (source) segment |
| Segment | translation | The result (target) segment |
Returns
| Type | Description |
|---|---|
| SearchResult | A new search result, which contains a duplicate of the source segment, and the translation segment. The origin is set to MachineTranslation. |
CreateSearchResultFromTranslation(Segment, Segment)
Creates a result from the given source and translation segments.
Declaration
protected virtual SearchResults CreateSearchResultFromTranslation(Segment searchSegment, Segment translation)
Parameters
| Type | Name | Description |
|---|---|---|
| Segment | searchSegment | The source segment for a which the translation was requested. |
| Segment | translation | The translated segment. |
Returns
| Type | Description |
|---|---|
| SearchResults | A SearchResults object representing the result of the translation. |
CreateSearchResultsFromTranslations(IList<Segment>, IList<Segment>)
Creates search results for the specified list of source segments and their translations.
Declaration
protected virtual IList<SearchResults> CreateSearchResultsFromTranslations(IList<Segment> searchSegments, IList<Segment> translations)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Segment> | searchSegments | The source segments that have been translated. |
| IList<Segment> | translations | The translations for the search segments. |
Returns
| Type | Description |
|---|---|
| IList<SearchResults> | A list of SearchResults objects representing the results of the translation. |
SearchMultipleSegmentsInternal(SearchSettings, IList<Segment>)
Obtains the translation for a set of segments from the machine translation service and returns it in the TranslationProposal field of a SearchResults collection. Obtaining the translation should, but does not have to, result in only a single server round-trip.
This method is abstract and must be implemented by derived classes.
To create a search result from a segment, you can use CreateSearchResult(Segment, Segment).
Declaration
protected abstract IList<SearchResults> SearchMultipleSegmentsInternal(SearchSettings settings, IList<Segment> segments)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings | The search settings to apply |
| IList<Segment> | segments | The segments to translate (must not be |
Returns
| Type | Description |
|---|---|
| IList<SearchResults> | A collection of SearchResults data structures if the translation was
successful, and |
SearchSegment(SearchSettings, Segment)
See SearchSegment(SearchSettings, Segment). The default implementation validates the settings and then call SearchSingleSegmentInternal(SearchSettings, Segment) to obtain the result.
Declaration
public virtual SearchResults SearchSegment(SearchSettings settings, Segment segment)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings | |
| Segment | segment |
Returns
| Type | Description |
|---|---|
| SearchResults |
SearchSegmentsMasked(SearchSettings, Segment[], bool[])
See SearchSegmentsMasked(SearchSettings, Segment[], bool[]). The default implementation collects the non-masked segments and calls SearchMultipleSegmentsInternal(SearchSettings, IList<Segment>) to obtain the result.
Declaration
public virtual SearchResults[] SearchSegmentsMasked(SearchSettings settings, Segment[] segments, bool[] mask)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings | |
| Segment[] | segments | |
| bool[] | mask |
Returns
| Type | Description |
|---|---|
| SearchResults[] |
SearchSegmentsMasked(SearchSettings, SubsegmentSearchSettings, SubsegmentSearchCondition, Segment[], bool[])
See SearchSegmentsMasked(SearchSettings, SubsegmentSearchSettings, SubsegmentSearchCondition, Segment[], bool[]). The default implementation
simply returns null.
Declaration
public virtual SegmentAndSubsegmentSearchResults[] SearchSegmentsMasked(SearchSettings settings, SubsegmentSearchSettings subsegmentSettings, SubsegmentSearchCondition condition, Segment[] segments, bool[] mask)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings | |
| SubsegmentSearchSettings | subsegmentSettings | |
| SubsegmentSearchCondition | condition | |
| Segment[] | segments | |
| bool[] | mask |
Returns
| Type | Description |
|---|---|
| SegmentAndSubsegmentSearchResults[] |
SearchSingleSegmentInternal(SearchSettings, Segment)
Obtains the translation for a single segment from the machine translation service and returns it in the TranslationProposal field of a SearchResults. Obtaining the translation may be through a round-trip to the server.
This method is abstract and must be implemented by derived classes.
To create a search result from a segment, you can use CreateSearchResult(Segment, Segment).
Declaration
protected abstract SearchResults SearchSingleSegmentInternal(SearchSettings settings, Segment segment)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings | The search settings to apply |
| Segment | segment | The segment to translate (must not be |
Returns
| Type | Description |
|---|---|
| SearchResults | A SearchResults data structure if the translation was
successful, and |
SearchText(SearchSettings, string)
See SearchText(SearchSettings, string). The default implementation
creates a new segment from the provided segment and calls
SearchSingleSegmentInternal(SearchSettings, Segment) to obtain the result.
Declaration
public virtual SearchResults SearchText(SearchSettings settings, string segment)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings | |
| string | segment |
Returns
| Type | Description |
|---|---|
| SearchResults |
SearchTranslationUnitsMasked(SearchSettings, SubsegmentSearchSettings, SubsegmentSearchCondition, TranslationUnit[], bool[])
See SearchTranslationUnitsMasked(SearchSettings, SubsegmentSearchSettings, SubsegmentSearchCondition, TranslationUnit[], bool[]). The default implementation
simply returns null.
Declaration
public virtual SegmentAndSubsegmentSearchResults[] SearchTranslationUnitsMasked(SearchSettings settings, SubsegmentSearchSettings subsegmentSettings, SubsegmentSearchCondition condition, TranslationUnit[] translationUnits, bool[] mask)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings | |
| SubsegmentSearchSettings | subsegmentSettings | |
| SubsegmentSearchCondition | condition | |
| TranslationUnit[] | translationUnits | |
| bool[] | mask |
Returns
| Type | Description |
|---|---|
| SegmentAndSubsegmentSearchResults[] |
SearchTranslationUnitsMasked(SearchSettings, TranslationUnit[], bool[])
See SearchTranslationUnitsMasked(SearchSettings, TranslationUnit[], bool[]). The default implementation collects the source segments of the translation units and then calls SearchSegmentsMasked(SearchSettings, Segment[], bool[]) to obtain the result.
Declaration
public virtual SearchResults[] SearchTranslationUnitsMasked(SearchSettings settings, TranslationUnit[] translationUnits, bool[] mask)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchSettings | settings | |
| TranslationUnit[] | translationUnits | |
| bool[] | mask |
Returns
| Type | Description |
|---|---|
| SearchResults[] |
Translate(Segment)
A convenience method which returns a single translation for the input segment, using default settings.
Declaration
public virtual Segment Translate(Segment segment)
Parameters
| Type | Name | Description |
|---|---|---|
| Segment | segment |
Returns
| Type | Description |
|---|---|
| Segment |
Translate(string)
A convenience method which returns a single translation for the input string, using default settings.
Declaration
public virtual string Translate(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text |
Returns
| Type | Description |
|---|---|
| string |
UpdateTranslationUnits(TranslationUnit[])
See UpdateTranslationUnits(TranslationUnit[]). The default implementation
simply returns null.
Declaration
public virtual ImportResult[] UpdateTranslationUnits(TranslationUnit[] translationUnits)
Parameters
| Type | Name | Description |
|---|---|---|
| TranslationUnit[] | translationUnits |
Returns
| Type | Description |
|---|---|
| ImportResult[] |