Class WordCounts
Represents the result of a word count.
Inheritance
Inherited Members
Namespace: Sdl.LanguagePlatform.TranslationMemory
Assembly: Sdl.LanguagePlatform.TranslationMemory.dll
Syntax
public class WordCounts
Constructors
WordCounts()
Initializes a new instance with default values. All counts will be set to 0.
Declaration
public WordCounts()
WordCounts(WordCounts)
Initializes a new instance with the values of another instance, creating a deep copy.
Declaration
public WordCounts(WordCounts other)
Parameters
Type | Name | Description |
---|---|---|
WordCounts | other | The instance to copy |
WordCounts(IList<Token>)
Initializes a new instance from the values in the provided token collection.
- Word and abbreviation tokens increment the character count by the length of the token text and increment the word count by one,
- Char sequence tokens (used in far-east tokenization) increment the word and character count by the length of the token text,
- Punctuation tokens only increment the character count, by the length of the token text,
- Date, time, variable, number, measurement, acronym, uri, and other text placeable tokens increment the word and character count like words do, but also increment the placeables count,
- Tag tokens increment the tag and placeable counts, but not the word or character counts,
- Whitespace tokens do not increment any counts (even not the character count),
- All other token types do not increment any counts.
- The segment count is set to 1, independent on the number and type of the tokens.
Declaration
public WordCounts(IList<Token> tokens)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<Token> | tokens | The token collection |
WordCounts(IList<Token>, WordCountsOptions, CultureCode)
Declaration
[Obsolete("Use CreateWordCountsAsync")]
public WordCounts(IList<Token> tokens, WordCountsOptions options, CultureCode culture)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<Token> | tokens | |
WordCountsOptions | options | |
Sdl.Core.Globalization.CultureCode | culture |
WordCounts(IList<Token>, Boolean, Boolean, Boolean, Boolean)
Initializes a new instance from the values in the provided token collection.
- Word and abbreviation tokens increment the character count by the length of the token text and increment the word count by one,
- Char sequence tokens (used in far-east tokenization) increment the word and character count by the length of the token text,
- Punctuation tokens only increment the character count, by the length of the token text,
- Date, time, variable, number, measurement, acronym, uri, and other text placeable tokens increment the word and character count like words do, but also increment the placeables count,
- Tag tokens increment the tag and placeable counts, but not the word or character counts,
- Whitespace tokens do not increment any counts (even not the character count),
- All other token types do not increment any counts.
- The segment count is set to 1, independent on the number and type of the tokens.
Declaration
public WordCounts(IList<Token> tokens, bool breakOnHyphen, bool breakOnDash, bool breakOnTag, bool breakOnApostrophe)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<Token> | tokens | The token collection |
System.Boolean | breakOnHyphen | If false, 2 words separated by a hyphen count as 1 |
System.Boolean | breakOnDash | If false, 2 words separated by a dash count as 1 |
System.Boolean | breakOnTag | If false, 2 words separated by a formatting tag count as 1 |
System.Boolean | breakOnApostrophe | If false, 2 words separated by an apostrophe count as 1 |
Properties
Characters
Gets or sets the character count.
Declaration
public int Characters { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsZero
Gets a boolean value which indicates whether all count values are zero or not.
Declaration
public bool IsZero { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Placeables
Gets or sets the placeable count.
Declaration
public int Placeables { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Segments
Gets or sets the segment count.
Declaration
public int Segments { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Tags
Gets or sets the tag count.
Declaration
public int Tags { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Words
Gets or sets the word count.
Declaration
public int Words { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Assign(WordCounts)
Overwrites the count values of this instance with the values of another instance.
Declaration
public void Assign(WordCounts other)
Parameters
Type | Name | Description |
---|---|---|
WordCounts | other | The instance which values to assign to this instance |
CreateWordCountsAsync(IList<Token>, WordCountsOptions, CultureCode, ICultureMetadataManager)
Declaration
public static Task<WordCounts> CreateWordCountsAsync(IList<Token> tokens, WordCountsOptions options, CultureCode cultureCode, ICultureMetadataManager cultureMetadataManager)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<Token> | tokens | |
WordCountsOptions | options | |
Sdl.Core.Globalization.CultureCode | cultureCode | |
Sdl.Core.Globalization.CultureMetadataManager.ICultureMetadataManager | cultureMetadataManager |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<WordCounts> |
Duplicate()
Creates a new instance that is a deep copy of this instance.
Declaration
public WordCounts Duplicate()
Returns
Type | Description |
---|---|
WordCounts | A new instance that is a deep copy of this instance. |
Inc(WordCounts)
Increments the count values of this instance with the count values of another instance.
Declaration
public void Inc(WordCounts other)
Parameters
Type | Name | Description |
---|---|---|
WordCounts | other | The other instance |