Class Rule
A phoneme rule.
Inheritance
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:
|
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
Name | Description |
---|---|
Rule(String, String, String, IPhonemeExpr) | Creates a new rule. |
Fields
Name | Description |
---|---|
ALL | |
ALL_STRINGS_RMATCHER |
Properties
Name | Description |
---|---|
LContext | Gets the left context pattern. This is a regular expression that must match to the left of the pattern. |
Pattern | Gets the pattern. This is a string-literal that must exactly match. |
Phoneme | Gets the phoneme. If the rule matches, this is the phoneme associated with the pattern match. |
RContext | Gets the right context pattern. This is a regular expression that must match to the right of the pattern. |
Methods
Name | Description |
---|---|
GetInstance(NameType, RuleType, LanguageSet) | Gets rules for a combination of name type, rule type and languages. |
GetInstance(NameType, RuleType, String) | Gets rules for a combination of name type, rule type and a single language. |
GetInstanceMap(NameType, RuleType, LanguageSet) | Gets rules for a combination of name type, rule type and languages. since 1.9 |
GetInstanceMap(NameType, RuleType, String) | Gets rules for a combination of name type, rule type and a single language. since 1.9 |
PatternAndContextMatches(ICharSequence, Int32) | Decides if the pattern and context match the input starting at a position. It is a match if the
LContext matches |
PatternAndContextMatches(StringBuilder, Int32) | Decides if the pattern and context match the input starting at a position. It is a match if the
LContext matches |
PatternAndContextMatches(String, Int32) | Decides if the pattern and context match the input starting at a position. It is a match if the
LContext matches |