Search Results for

    Show / Hide Table of Contents

    Class TokenBundle

    A special Token which represents a set of alternatives (i.e. an ambiguous analysis) of other tokens which cover the exactly same input span.

    Inheritance
    System.Object
    SegmentElement
    Token
    TokenBundle
    Implements
    System.Collections.Generic.IEnumerable<PrioritizedToken>
    System.Collections.IEnumerable
    Inherited Members
    Token.SetTokenType(TokenType)
    Token.Equals(Object)
    Token.GetHashCode()
    Token.GetWeakHashCode()
    Token.GetBundleSimilarity(SegmentElement)
    Token.GetIdentityStringAsync()
    Token.TokenizationContext
    Token.Text
    Token.Span
    Token.Type
    Token.IsWord
    Token.IsPunctuation
    Token.IsWhitespace
    Token.Culture
    SegmentElement.GetSimilarity(SegmentElement)
    SegmentElement.GetSimilarity(SegmentElement, Boolean)
    SegmentElement.GetSimilarityAsync(SegmentElement)
    SegmentElement.GetSimilarityAsync(SegmentElement, Boolean)
    System.Object.ToString()
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Sdl.LanguagePlatform.Core.Tokenization
    Assembly: Sdl.LanguagePlatform.Core.dll
    Syntax
    public class TokenBundle : Token, IEnumerable<PrioritizedToken>, IEnumerable

    Constructors

    TokenBundle(Token, Int32)

    Initializes a new instance with the specified values.

    Declaration
    public TokenBundle(Token t, int priority)
    Parameters
    Type Name Description
    Token t

    The first token in the set of alternatives (must not be null). It is also used to set the Text of the bundle.

    System.Int32 priority

    The priority to assign to the first token in the bundle

    TokenBundle(IList<PrioritizedToken>)

    Initializes a new instance with a list of prioritized tokens.

    Declaration
    public TokenBundle(IList<PrioritizedToken> items)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<PrioritizedToken> items

    The items to add to the list of alternatives. Only a shallow copy is made.

    Properties

    Count

    Gets the number of elements in the collection.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    IsPlaceable

    IsPlaceable. Is true if any of the alternatives is a placeable token.

    Declaration
    public override bool IsPlaceable { get; }
    Property Value
    Type Description
    System.Boolean
    Overrides
    Token.IsPlaceable

    IsSubstitutable

    IsSubstitutable. Is true if any of the alternatives is a substitutable token.

    Declaration
    public override bool IsSubstitutable { get; }
    Property Value
    Type Description
    System.Boolean
    Overrides
    Token.IsSubstitutable

    Item[Int32]

    Gets the prioritized token at the specified index position. If the index position is invalid, an exception is thrown.

    Declaration
    public PrioritizedToken this[int index] { get; }
    Parameters
    Type Name Description
    System.Int32 index

    The index

    Property Value
    Type Description
    PrioritizedToken

    The prioritized token at the index position

    Methods

    AcceptSegmentElementVisitor(ISegmentElementVisitor)

    Invalid for this class. Will throw a System.InvalidOperationException

    Declaration
    public override void AcceptSegmentElementVisitor(ISegmentElementVisitor visitor)
    Parameters
    Type Name Description
    ISegmentElementVisitor visitor

    (ignored)

    Overrides
    SegmentElement.AcceptSegmentElementVisitor(ISegmentElementVisitor)

    Add(Token, Int32)

    Adds a new token to the set of alternatives. Potential duplicates are kept.

    Declaration
    public void Add(Token t, int priority)
    Parameters
    Type Name Description
    Token t

    The token

    System.Int32 priority

    The priority assigned to the token

    Add(Token, Int32, Boolean)

    Adds a new token to the set of alternatives.

    Declaration
    public void Add(Token t, int priority, bool keepDuplicates)
    Parameters
    Type Name Description
    Token t

    The token

    System.Int32 priority

    The priority assigned to the token

    System.Boolean keepDuplicates

    If true, the token will always be added. If false, and the collection contains a token which Equals t, only the one with the higher priority will be kept.

    Contains(Token)

    Determines whether the specified token is contained in the set of alternatives.

    Declaration
    public bool Contains(Token t)
    Parameters
    Type Name Description
    Token t

    The token to search

    Returns
    Type Description
    System.Boolean

    true if the token is equal to one of the alternatives, and false otherwise

    Duplicate()

    Invalid for this class. Will throw a System.InvalidOperationException

    Declaration
    public override SegmentElement Duplicate()
    Returns
    Type Description
    SegmentElement
    Overrides
    SegmentElement.Duplicate()

    GetBest()

    Obtains the token with the highest priority in the set of alternatives. If two tokens have the same priority, the first one will be the winner.

    Declaration
    public Token GetBest()
    Returns
    Type Description
    Token

    The token with the highest priority in the set of alternatives.

    GetEnumerator()

    Gets an enumerator to iterate through the list of alternatives.

    Declaration
    public IEnumerator<PrioritizedToken> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<PrioritizedToken>

    An enumerator

    GetTokenType()

    Type. Returns the token type of the first alternative in the collection. However, be aware that the alternatives may represent different token types.

    Declaration
    protected override TokenType GetTokenType()
    Returns
    Type Description
    TokenType
    Overrides
    Token.GetTokenType()

    SortByDecreasingPriority()

    Sorts the set of alternatives by decreasing priority.

    Declaration
    public void SortByDecreasingPriority()

    Explicit Interface Implementations

    IEnumerable.GetEnumerator()

    Gets an enumerator to iterate through the list of alternatives.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    System.Collections.IEnumerator

    An enumerator

    Implements

    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable

    On this page

    • Constructors
      • TokenBundle(Token, Int32)
      • TokenBundle(IList<PrioritizedToken>)
    • Properties
      • Count
      • IsPlaceable
      • IsSubstitutable
      • Item[Int32]
    • Methods
      • AcceptSegmentElementVisitor(ISegmentElementVisitor)
      • Add(Token, Int32)
      • Add(Token, Int32, Boolean)
      • Contains(Token)
      • Duplicate()
      • GetBest()
      • GetEnumerator()
      • GetTokenType()
      • SortByDecreasingPriority()
    • Explicit Interface Implementations
      • IEnumerable.GetEnumerator()
    • Implements
    Back to top Generated by DocFX