Class Rule
A phoneme rule.
Inheritance
Inherited Members
Namespace: Lucene.Net.Analysis.Phonetic.Language.Bm
Assembly: Lucene.Net.Analysis.Phonetic.dll
Syntax
public class Rule
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:
|
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 SourceRule(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 SourceALL
Declaration
public const string ALL = "ALL"
Field Value
Type | Description |
---|---|
System.String |
ALL_STRINGS_RMATCHER
Declaration
public static readonly IRPattern ALL_STRINGS_RMATCHER
Field Value
Type | Description |
---|---|
IRPattern |
Properties
| Improve this Doc View SourceLContext
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 |
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 |
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 |
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 SourceGetInstance(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 |
---|---|
System.Collections.Generic.IList<Rule> | A list of Rules that apply. |
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 |
---|---|
System.Collections.Generic.IList<Rule> | A list of Rules that apply. |
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 |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Collections.Generic.IList<Rule>> | A map containing all Rules that apply, grouped by the first character of the rule pattern. |
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 |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Collections.Generic.IList<Rule>> | A map containing all Rules that apply, grouped by the first character of the rule pattern. |
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 |
---|---|---|
J2N.Text.ICharSequence | input | The input J2N.Text.ICharSequence. |
System.Int32 | i | The int position within the input. |
Returns
Type | Description |
---|---|
System.Boolean |
|
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.String. |
System.Int32 | i | The int position within the input. |
Returns
Type | Description |
---|---|
System.Boolean |
|
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 |
---|---|---|
System.Text.StringBuilder | input | The input System.Text.StringBuilder. |
System.Int32 | i | The int position within the input. |
Returns
Type | Description |
---|---|
System.Boolean |
|