Class Lang
Language guessing utility.
Inheritance
Assembly: Lucene.Net.Analysis.Phonetic.dll
Syntax
public class Lang : object
Remarks
This class encapsulates rules used to guess the possible languages that a word originates from. This is done by reference to a whole series of rules distributed in resource files.
Instances of this class are typically managed through the static factory method GetInstance(NameType). Unless you are developing your own language guessing rules, you will not need to interact with this class directly.
This class is intended to be immutable and thread-safe.
Lang resources
Language guessing 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.lang.txt
The format of these resources is the following:
Rules: |
Whitespace separated strings.
There should be 3 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. |
Port of lang.php
since 1.6
Methods
Name | Description |
---|---|
GetInstance(NameType) | Gets a Lang instance for one of the supported NameTypes. |
GuessLanguage(String) | Guesses the language of a word. |
GuessLanguages(String) | Guesses the languages of a word. |
LoadFromResource(String, Languages) | Loads language rules from a resource. In normal use, you will obtain instances of Lang through the GetInstance(NameType) method. You will only need to call this yourself if you are developing custom language mapping rules. |