Show / Hide Table of Contents

    Class Rule

    A phoneme rule.

    Inheritance
    System.Object
    Rule
    Namespace: Lucene.Net.Analysis.Phonetic.Language.Bm
    Assembly: Lucene.Net.Analysis.Phonetic.dll
    Syntax
    public class Rule : object
    Remarks

    Rules have a pattern, left context, right context, output phoneme, set of languages for which they apply and a logical flag indicating if all languages must be in play. A rule matches if:

    • the pattern matches at the current position
    • the string up until the beginning of the pattern matches the left context
    • the string from the end of the pattern matches the right context
    • logical is ALL and all languages are in scope; or
    • logical is any other value and at least one language is in scope

    Rules are typically generated by parsing rules resources. In normal use, there will be no need for the user to explicitly construct their own.

    Rules are immutable and thread-safe.

    Rules resources

    Rules are typically loaded from resource files. These are UTF-8 encoded text files. They are systematically named following the pattern: Lucene.Net.Analysis.Phonetic.Language.Bm.NameTypeRuleType[language].txt

    The format of these resources is the following:

    Rules: whitespace separated, double-quoted strings. There should be 4 columns to each row, and these will be interpreted as:
    1. pattern
    2. left context
    3. right context
    4. phoneme
    End-of-line comments:Any occurrence of '//' will cause all text following on that line to be discarded as a comment.
    Multi-line comments:Any line starting with '/' will start multi-line commenting mode. This will skip all content until a line ending in '' and '/' is found.
    Blank lines:All blank lines will be skipped.

    since 1.6

    Constructors

    | Improve this Doc View Source

    Rule(String, String, String, IPhonemeExpr)

    Creates a new rule.

    Declaration
    public Rule(string pattern, string lContext, string rContext, IPhonemeExpr phoneme)
    Parameters
    Type Name Description
    System.String pattern

    The pattern.

    System.String lContext

    The left context.

    System.String rContext

    The right context.

    IPhonemeExpr phoneme

    The resulting phoneme.

    Fields

    | Improve this Doc View Source

    ALL

    Declaration
    public static readonly string ALL
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    ALL_STRINGS_RMATCHER

    Declaration
    public static readonly IRPattern ALL_STRINGS_RMATCHER
    Field Value
    Type Description
    IRPattern

    Properties

    | Improve this Doc View Source

    LContext

    Gets the left context pattern. This is a regular expression that must match to the left of the pattern.

    Declaration
    public virtual IRPattern LContext { get; }
    Property Value
    Type Description
    IRPattern
    | Improve this Doc View Source

    Pattern

    Gets the pattern. This is a string-literal that must exactly match.

    Declaration
    public virtual string Pattern { get; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    Phoneme

    Gets the phoneme. If the rule matches, this is the phoneme associated with the pattern match.

    Declaration
    public virtual IPhonemeExpr Phoneme { get; }
    Property Value
    Type Description
    IPhonemeExpr
    | Improve this Doc View Source

    RContext

    Gets the right context pattern. This is a regular expression that must match to the right of the pattern.

    Declaration
    public virtual IRPattern RContext { get; }
    Property Value
    Type Description
    IRPattern

    Methods

    | Improve this Doc View Source

    GetInstance(NameType, RuleType, LanguageSet)

    Gets rules for a combination of name type, rule type and languages.

    Declaration
    public static IList<Rule> GetInstance(NameType nameType, RuleType rt, LanguageSet langs)
    Parameters
    Type Name Description
    NameType nameType

    The NameType to consider.

    RuleType rt

    The RuleType to consider.

    LanguageSet langs

    The set of languages to consider.

    Returns
    Type Description
    IList<Rule>

    A list of Rules that apply.

    | Improve this Doc View Source

    GetInstance(NameType, RuleType, String)

    Gets rules for a combination of name type, rule type and a single language.

    Declaration
    public static IList<Rule> GetInstance(NameType nameType, RuleType rt, string lang)
    Parameters
    Type Name Description
    NameType nameType

    The NameType to consider.

    RuleType rt

    The RuleType to consider.

    System.String lang

    The language to consider.

    Returns
    Type Description
    IList<Rule>

    A list of Rules that apply.

    | Improve this Doc View Source

    GetInstanceMap(NameType, RuleType, LanguageSet)

    Gets rules for a combination of name type, rule type and languages.

    since 1.9

    Declaration
    public static IDictionary<string, IList<Rule>> GetInstanceMap(NameType nameType, RuleType rt, LanguageSet langs)
    Parameters
    Type Name Description
    NameType nameType

    The NameType to consider.

    RuleType rt

    The RuleType to consider.

    LanguageSet langs

    The set of languages to consider.

    Returns
    Type Description
    IDictionary<System.String, IList<Rule>>

    A map containing all Rules that apply, grouped by the first character of the rule pattern.

    | Improve this Doc View Source

    GetInstanceMap(NameType, RuleType, String)

    Gets rules for a combination of name type, rule type and a single language.

    since 1.9

    Declaration
    public static IDictionary<string, IList<Rule>> GetInstanceMap(NameType nameType, RuleType rt, string lang)
    Parameters
    Type Name Description
    NameType nameType

    The NameType to consider.

    RuleType rt

    The RuleType to consider.

    System.String lang

    The language to consider.

    Returns
    Type Description
    IDictionary<System.String, IList<Rule>>

    A map containing all Rules that apply, grouped by the first character of the rule pattern.

    | Improve this Doc View Source

    PatternAndContextMatches(ICharSequence, Int32)

    Decides if the pattern and context match the input starting at a position. It is a match if the LContext matches input up to i, Pattern matches at i and RContext matches from the end of the match of Pattern to the end of input.

    Declaration
    public virtual bool PatternAndContextMatches(ICharSequence input, int i)
    Parameters
    Type Name Description
    ICharSequence input

    The input ICharSequence.

    System.Int32 i

    The int position within the input.

    Returns
    Type Description
    System.Boolean

    true if the pattern and left/right context match, false otherwise.

    | Improve this Doc View Source

    PatternAndContextMatches(StringBuilder, Int32)

    Decides if the pattern and context match the input starting at a position. It is a match if the LContext matches input up to i, Pattern matches at i and RContext matches from the end of the match of Pattern to the end of input.

    Declaration
    public virtual bool PatternAndContextMatches(StringBuilder input, int i)
    Parameters
    Type Name Description
    StringBuilder input

    The input .

    System.Int32 i

    The int position within the input.

    Returns
    Type Description
    System.Boolean

    true if the pattern and left/right context match, false otherwise.

    | Improve this Doc View Source

    PatternAndContextMatches(String, Int32)

    Decides if the pattern and context match the input starting at a position. It is a match if the LContext matches input up to i, Pattern matches at i and RContext matches from the end of the match of Pattern to the end of input.

    Declaration
    public virtual bool PatternAndContextMatches(string input, int i)
    Parameters
    Type Name Description
    System.String input

    The input .

    System.Int32 i

    The int position within the input.

    Returns
    Type Description
    System.Boolean

    true if the pattern and left/right context match, false otherwise.

    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)