Class FileBasedTranslationMemory
Represents a bilingual file-based translation memory.
Implements
Inherited Members
Namespace: Sdl.LanguagePlatform.TranslationMemoryApi
Assembly: Sdl.LanguagePlatform.TranslationMemoryApi.dll
Syntax
public class FileBasedTranslationMemory : AbstractLocalTranslationMemory, IFileBasedTranslationMemory, IAlignableTranslationMemory, ITranslationMemory2015, ITranslationMemory, ITranslationProvider, IReindexableTranslationMemory, ILocalTranslationMemory, IAdvancedContextTranslationMemory
Constructors
FileBasedTranslationMemory(String)
Opens an existing file-based translation memory.
Declaration
public FileBasedTranslationMemory(string tmFilePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | tmFilePath | The absolute path of the translation memory file. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.IO.FileNotFoundException | Thrown if |
FileBasedTranslationMemory(String, String)
Opens an existing file-based translation memory and unlocks it with the specified password.
Declaration
public FileBasedTranslationMemory(string tmFilePath, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | tmFilePath | The absolute path of the translation memory file. |
System.String | password | The password. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.IO.FileNotFoundException | Thrown if |
FileBasedTranslationMemory(String, String, CultureInfo, CultureInfo, FuzzyIndexes, BuiltinRecognizers, TokenizerFlags, WordCountFlags)
Creates a new file-based translation memory.
Declaration
public FileBasedTranslationMemory(string tmFilePath, string description, CultureInfo sourceLanguage, CultureInfo targetLanguage, FuzzyIndexes indexes, BuiltinRecognizers recognizers, TokenizerFlags tokenizerFlags, WordCountFlags wordCountFlags)
Parameters
Type | Name | Description |
---|---|---|
System.String | tmFilePath | The absolute path where the translation memory file should be created. |
System.String | description | A description for the translation memory. |
System.Globalization.CultureInfo | sourceLanguage | A region-qualified culture, representing the source language. |
System.Globalization.CultureInfo | targetLanguage | A region-qualified culture, representing the target language. |
FuzzyIndexes | indexes | The set of fuzzy indexes that should be created in this translation memory. |
BuiltinRecognizers | recognizers | Recognizer settings. |
TokenizerFlags | tokenizerFlags | Flags affecting tokenizer behaviour for this TM |
WordCountFlags | wordCountFlags | Flags affecting word count behaviour for this TM |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentException | Thrown when |
FileBasedTranslationMemory(String, String, CultureInfo, CultureInfo, FuzzyIndexes, BuiltinRecognizers, TokenizerFlags, WordCountFlags, Boolean)
Creates a new file-based translation memory.
Declaration
public FileBasedTranslationMemory(string tmFilePath, string description, CultureInfo sourceLanguage, CultureInfo targetLanguage, FuzzyIndexes indexes, BuiltinRecognizers recognizers, TokenizerFlags tokenizerFlags, WordCountFlags wordCountFlags, bool supportsAlignmentData)
Parameters
Type | Name | Description |
---|---|---|
System.String | tmFilePath | The absolute path where the translation memory file should be created. |
System.String | description | A description for the translation memory. |
System.Globalization.CultureInfo | sourceLanguage | A region-qualified culture, representing the source language. |
System.Globalization.CultureInfo | targetLanguage | A region-qualified culture, representing the target language. |
FuzzyIndexes | indexes | The set of fuzzy indexes that should be created in this translation memory. |
BuiltinRecognizers | recognizers | Recognizer settings. |
TokenizerFlags | tokenizerFlags | Flags affecting tokenizer behaviour for this TM |
WordCountFlags | wordCountFlags | Flags affecting word count behaviour for this TM |
System.Boolean | supportsAlignmentData | True if the translation memory should support fine-grained alignment of content, false otherwise |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentException | Thrown when |
FileBasedTranslationMemory(String, String, CultureInfo, CultureInfo, FuzzyIndexes, BuiltinRecognizers, TokenizerFlags, WordCountFlags, Boolean, TextContextMatchType, Boolean, Boolean)
Creates a new file-based translation memory.
Declaration
public FileBasedTranslationMemory(string tmFilePath, string description, CultureInfo sourceLanguage, CultureInfo targetLanguage, FuzzyIndexes indexes, BuiltinRecognizers recognizers, TokenizerFlags tokenizerFlags, WordCountFlags wordCountFlags, bool supportsAlignmentData, TextContextMatchType textContextMatchType, bool usesIdContextMatch, bool usesLegacyHashes)
Parameters
Type | Name | Description |
---|---|---|
System.String | tmFilePath | The absolute path where the translation memory file should be created. |
System.String | description | A description for the translation memory. |
System.Globalization.CultureInfo | sourceLanguage | A region-qualified culture, representing the source language. |
System.Globalization.CultureInfo | targetLanguage | A region-qualified culture, representing the target language. |
FuzzyIndexes | indexes | The set of fuzzy indexes that should be created in this translation memory. |
BuiltinRecognizers | recognizers | Recognizer settings. |
TokenizerFlags | tokenizerFlags | Flags affecting tokenizer behaviour for this TM |
WordCountFlags | wordCountFlags | Flags affecting word count behaviour for this TM |
System.Boolean | supportsAlignmentData | True if the translation memory should support fine-grained alignment of content, false otherwise |
TextContextMatchType | textContextMatchType | The type of text context matching the TM should use |
System.Boolean | usesIdContextMatch | If true, indicates the TM should support IdContexMatch |
System.Boolean | usesLegacyHashes | True if the translation memory should use legacy segment hashing, for data conversion purposes |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentException | Thrown when |
FileBasedTranslationMemory(Uri)
Opens an existing file-based translation memory given the Uri for a FileBasedTranslationMemory class.
Declaration
public FileBasedTranslationMemory(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uri | The Uri of a FileBasedTranslationMemory class. |
Properties
AlignedPredatedTranslationUnitCount
Gets the number of TUs that were added after the model used to align them was built, but before the latest model was built.
Declaration
public int AlignedPredatedTranslationUnitCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
AlignerDefinition
Gets the AlignerDefinition that has been set for this TM, or null if there is none
Declaration
public AlignerDefinition AlignerDefinition { get; }
Property Value
Type | Description |
---|---|
AlignerDefinition |
CanBuildModel
Indicates whether the TM has enough data for the translation model associated with it to be built
Declaration
public bool CanBuildModel { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
CanReportReindexRequired
Returns true for file-based TMs capable of reporting whether TUs require reindexing, or false for legacy TMs that do not support this capability.
Declaration
public bool CanReportReindexRequired { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
FGASupport
Returns the status of fine-grained-alignment support for the TM
Declaration
public FGASupport FGASupport { get; set; }
Property Value
Type | Description |
---|---|
FGASupport |
FilePath
Gets the file path.
Declaration
public string FilePath { get; }
Property Value
Type | Description |
---|---|
System.String | The file path. |
HasAdministratorPassword
Gets a value indicating whether this instance has an administrator password.
Declaration
public bool HasAdministratorPassword { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
HasMaintenancePassword
Gets a value indicating whether this instance has maintenance password.
Declaration
public bool HasMaintenancePassword { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
HasReadOnlyPassword
Gets a value indicating whether this instance has read only password.
Declaration
public bool HasReadOnlyPassword { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
HasReadWritePassword
Gets a value indicating whether this instance has read write password.
Declaration
public bool HasReadWritePassword { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsProtected
Gets a value indicating whether this instance is protected one or more passwords.
Declaration
public bool IsProtected { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsUnlockedWithSufficientPermissions
Determines whether the file based translation memory has been unlocked with sufficient permissions to be deemed available. When null, no attempt has been made to unlock the file based translation memory and obtain sufficient permission. When false, an attempt has been made to unlock the file based translation memory and obtain sufficient permission that failed. When true, an attempt has been made to unlock the file based translation memory and obtain sufficient permission that succeeded. If this is false then StatusInfo. Available will be false with a message "Not unlocked with sufficient permissions." This property should be set by the calling code after the user has been challenged.
Declaration
public bool? IsUnlockedWithSufficientPermissions { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Boolean> |
ModelDetails
Provides details of the translation model associated with this file-based TM
Declaration
public TranslationModelDetails ModelDetails { get; }
Property Value
Type | Description |
---|---|
TranslationModelDetails |
ReindexRequired
Returns true if any TUs require reindexing, based on the value of their tokenization_signature_hash column, false otherwise, or null if the TM is a legacy file-based TM that does not have this column.
Declaration
public bool? ReindexRequired { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Boolean> |
ShouldAlign
Indicates whether 'quick' alignment (i.e. alignment of any unaligned TUs, plus postdated TUs for which a newer model is now available) is recommended
Declaration
public bool ShouldAlign { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShouldBuildModel
Indicates whether a build (or rebuild) of the translation model is recommended
Declaration
public bool ShouldBuildModel { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Recommendation considers a significant amount of new content has been added to the TM since the model was built (see TranslationUnitNewerThanModelCount
StatusInfo
Gets the status info for the translation memory. A file-based translation memory is considered available if the translation memory file exists and if the translation memory has been unlocked by calling Unlock(String) (in case the translation memory) is password protected.
Declaration
public override ProviderStatusInfo StatusInfo { get; }
Property Value
Type | Description |
---|---|
ProviderStatusInfo |
Overrides
TextContextMatchType
Returns the type of TextContextMatchType specified when the TM was created
Declaration
public TextContextMatchType TextContextMatchType { get; }
Property Value
Type | Description |
---|---|
TextContextMatchType |
TokenizerFlags
Gets or sets the flags affecting tokenizer behaviour for this TM.
Declaration
public TokenizerFlags TokenizerFlags { get; set; }
Property Value
Type | Description |
---|---|
TokenizerFlags |
TranslationUnitNewerThanModelCount
Gets the number of TUs that have been added subsequent to the date of the translation model
Declaration
public int TranslationUnitNewerThanModelCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
TuCountForReindex
Returns the number of TUs that require reindexing, based on the value of their tokenization_signature_hash column, or -1 if the TM is a legacy file-based TM that does not have this column.
Declaration
public int TuCountForReindex { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
UnalignedTranslationUnitCount
Gets the number of TUs that do not have fine-grained alignment information.
Declaration
public int UnalignedTranslationUnitCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
UserName
Sets the user name on the container to override the default windows user ID
Declaration
public string UserName { set; }
Property Value
Type | Description |
---|---|
System.String |
UsesIdContextMatching
Returns true if the TM was created with support for ID-based context matching
Declaration
public bool UsesIdContextMatching { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
UsesLegacyHashes
Returns true if the TM is using legacy segment hashing (and can therefore consume legacy context information in TMX without conversion)
Declaration
public bool UsesLegacyHashes { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
WordCountFlags
Gets or sets the flags affecting word count behaviour for this TM.
Declaration
public WordCountFlags WordCountFlags { get; set; }
Property Value
Type | Description |
---|---|
WordCountFlags |
Methods
AlignTranslationUnits(Boolean, Boolean, ref RegularIterator)
Performs fine-grained alignment on translation units
Declaration
public bool AlignTranslationUnits(bool unalignedOnly, bool unalignedOrPostdatedOnly, ref RegularIterator iter)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | unalignedOnly | If true, will only operate on translation units that do not already have any alignment information |
System.Boolean | unalignedOrPostdatedOnly | If true, will only operate on translation units that do not already have any alignment information or are postdated (see remarks). In this case, |
RegularIterator | iter |
Returns
Type | Description |
---|---|
System.Boolean | True if there are more translation units to process, false otherwise |
Remarks
An aligned, postdated TU is one that has been aligned, but was added to the TM after the translation model used for alignment was built.
AlignTranslationUnits(Boolean, Boolean, CancellationToken, IProgress<Int32>)
Performs bulk fine-grained alignment on translation units in a TM
Declaration
public void AlignTranslationUnits(bool unalignedOnly, bool unalignedOrPostdatedOnly, CancellationToken token, IProgress<int> progress)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | unalignedOnly | If true, will only operate on translation units that do not already have any alignment information |
System.Boolean | unalignedOrPostdatedOnly | If true, will only operate on translation units that do not already have any alignment information or are postdated (see remarks). In this case, |
System.Threading.CancellationToken | token | A CancellationToken whose CancellationTokenSource can be used to cancel the alignment |
System.IProgress<System.Int32> | progress |
Remarks
An aligned, postdated TU is one that has been aligned, but was added to the TM after the translation model used for alignment was built.
BuildModel()
Builds the translation model associated with this file-based TM
Declaration
public void BuildModel()
ClearAlignmentData()
Deletes any fine-grained alignment data from the TM
Declaration
public void ClearAlignmentData()
ClearModel()
Declaration
public void ClearModel()
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The System.Object to compare with this instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
Exceptions
Type | Condition |
---|---|
System.NullReferenceException | The |
GetFileBasedTranslationMemoryFilePath(Uri)
Gets the file-based translation memory file path from the given Uri.
Declaration
public static string GetFileBasedTranslationMemoryFilePath(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uri | A file-based translation memory Uri. |
Returns
Type | Description |
---|---|
System.String | file-based translation memory file path |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when |
GetFileBasedTranslationMemoryName(Uri)
Gets the file-based translation memory file name (excluding the path) from the given Uri.
Declaration
public static string GetFileBasedTranslationMemoryName(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uri | A file-based translation memory Uri. |
Returns
Type | Description |
---|---|
System.String | The file-based translation memory file name, excluding the path. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when |
GetFileBasedTranslationMemoryScheme()
Gets the file-based translation memory scheme.
Declaration
public static string GetFileBasedTranslationMemoryScheme()
Returns
Type | Description |
---|---|
System.String | file-based translation memory scheme |
GetFileBasedTranslationMemoryUri(String)
Gets the file-based translation memory Uri from the given file path.
Declaration
public static Uri GetFileBasedTranslationMemoryUri(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | file path |
Returns
Type | Description |
---|---|
System.Uri | file-based translation memory Uri |
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
GetValidAccessModes(String)
Returns the list of access modes that are valid for the given permission. So if the password is set for one of the returned access modes, the specified permission will be granted. For example, if the permission is "batchedittu", the valid access modes would be Maintenance and Administrator.
Declaration
public IList<TranslationMemoryFileAccessMode> GetValidAccessModes(string permission)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<TranslationMemoryFileAccessMode> |
HasAccessModePermission(TranslationMemoryFileAccessMode)
Returns true if permission is granted to access the TM with the specified access mode.
Declaration
public bool HasAccessModePermission(TranslationMemoryFileAccessMode accessMode)
Parameters
Type | Name | Description |
---|---|---|
TranslationMemoryFileAccessMode | accessMode |
Returns
Type | Description |
---|---|
System.Boolean |
HasPermission(String)
Checks whether the current user has the specified permission on this translation memory.
Declaration
public override bool HasPermission(string permission)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission | A permission ID. See TranslationMemoryPermissions. |
Returns
Type | Description |
---|---|
System.Boolean | True if the user has the specified permission for this TM. |
Overrides
IsFileBasedTranslationMemory(Uri)
Determines whether the given Uri represents a file-based translation memory.
Declaration
public static bool IsFileBasedTranslationMemory(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uri | The Uri to check. |
Returns
Type | Description |
---|---|
System.Boolean | Whether |
IsPasswordSet(String)
Determines whether a specified password is already in use on the TM.
Declaration
public TranslationMemoryFileAccessMode? IsPasswordSet(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | The password to check |
Returns
Type | Description |
---|---|
System.Nullable<TranslationMemoryFileAccessMode> | The access mode that the password is set for, or null if the password is not already in use on the TM |
MeasureModelFitness(ref RegularIterator, Boolean)
Measures how well the model 'fits' the TM content, by counting out-of-vocabulary words
Declaration
public TranslationModelFitness MeasureModelFitness(ref RegularIterator iterator, bool postdatedOrUnalignedOnly)
Parameters
Type | Name | Description |
---|---|---|
RegularIterator | iterator | |
System.Boolean | postdatedOrUnalignedOnly |
Returns
Type | Description |
---|---|
TranslationModelFitness |
OnProgress(TranslationModelProgressEventArgs)
Declaration
protected void OnProgress(TranslationModelProgressEventArgs progressEventArgs)
Parameters
Type | Name | Description |
---|---|---|
TranslationModelProgressEventArgs | progressEventArgs |
OnProgress(Object, TranslationModelProgressEventArgs)
Declaration
protected void OnProgress(object sender, TranslationModelProgressEventArgs progressEventArgs)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
TranslationModelProgressEventArgs | progressEventArgs |
RefreshStatusInfo()
Refreshes the current status information.
Declaration
public override void RefreshStatusInfo()
Overrides
SelectiveReindexTranslationUnits(CancellationToken, IProgress<Int32>)
Provides similar functionality to ReindexTranslationUnits, except that only TUs that require reindexing are reindexed, based on the value of their tokenization_signature_hash column, or no TUs if the TM is a legacy file-based TM that does not have this column.
Declaration
public void SelectiveReindexTranslationUnits(CancellationToken token, IProgress<int> progress)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | token | |
System.IProgress<System.Int32> | progress |
SetAdministratorPassword(String)
Sets the administrator password and unlocks the TM so the TM is open in administrator mode.
Declaration
public void SetAdministratorPassword(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | The password; or null to remove the password restriction. Note that setting this password to null also sets all the other passwords to null (if they are currently set). |
SetMaintenancePassword(String)
Sets the maintenance password.
Declaration
public void SetMaintenancePassword(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | The password; or null to remove the password restriction. Note that setting this password to null also sets all the read-write and read-only passwords to null (if they are currently set). |
Remarks
This method just updates the password stored in the TM. It does not unlock the translation memory. Use Unlock(String) to do this.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when trying to set a maintenance password without having set an administrator password. |
SetReadOnlyPassword(String)
Sets the read only password.
Declaration
public void SetReadOnlyPassword(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | The password; or null to remove the password restriction. |
Remarks
This method just updates the password stored in the TM. It does not unlock the translation memory. Use Unlock(String) to do this.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when trying to set a read-only password without having set administrator, maintenance and read-write passwords. |
SetReadWritePassword(String)
Sets the read write password.
Declaration
public void SetReadWritePassword(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | The password; or null to remove the password restriction. Note that setting this password to null also sets the read-only passwords to null (if it is currently set). |
Remarks
This method just updates the password stored in the TM. It does not unlock the translation memory. Use Unlock(String) to do this.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when trying to set a read-write password without having set administrator and maintenance passwords. |
Unlock(String)
Unlocks the translation memory with the specified password.
Declaration
public void Unlock(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password |
Events
TranslationModelProgress
Reports the progress of building a translation model
Declaration
public event EventHandler<TranslationModelProgressEventArgs> TranslationModelProgress
Event Type
Type | Description |
---|---|
System.EventHandler<TranslationModelProgressEventArgs> |