C# 클래스 org.apache.lucene.analysis.compound.hyphenation.HyphenationTree

This tree structure stores the hyphenation patterns in an efficient way for fast lookup. It provides the provides the method to hyphenate a word. This class has been taken from the Apache FOP project (http://xmlgraphics.apache.org/fop/). They have been slightly modified.
상속: TernaryTree, PatternConsumer
파일 보기 프로젝트 열기: paulirwin/lucene.net 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
classmap TernaryTree
stoplist List>.Dictionary
vspace ByteVector

공개 메소드들

메소드 설명
HyphenationTree ( ) : System
addClass ( string chargroup ) : void

Add a character class to the tree. It is used by PatternParser PatternParser as callback to add character classes. Character classes define the valid word characters for hyphenation. If a word contains a character not defined in any of the classes, it is not hyphenated. It also defines a way to normalize the characters in order to compare them with the stored patterns. Usually pattern files use only lower case characters, in this case a class for letter 'a', for example, should be defined as "aA", the first character being the normalization char.

addException ( string word, List hyphenatedword ) : void

Add an exception to the tree. It is used by PatternParser PatternParser class as callback to store the hyphenation exceptions.

addPattern ( string pattern, string ivalue ) : void

Add a pattern to the tree. Mainly, to be used by PatternParser PatternParser class as callback to add a pattern to the tree.

findPattern ( string pat ) : string
hyphenate ( char w, int offset, int len, int remainCharCount, int pushCharCount ) : Hyphenation

Hyphenate word and return an array of hyphenation points.

hyphenate ( string word, int remainCharCount, int pushCharCount ) : Hyphenation

Hyphenate word and return a Hyphenation object.

loadPatterns ( File f ) : void

Read hyphenation patterns from an XML file.

loadPatterns ( InputSource source ) : void

Read hyphenation patterns from an XML file.

printStats ( PrintStream @out ) : void

보호된 메소드들

메소드 설명
getValues ( int k ) : sbyte[]
hstrcmp ( char s, int si, char t, int ti ) : int

String compare, returns 0 if equal or t is a substring of s

packValues ( string values ) : int

Packs the values by storing them in 4 bits, two values into a byte Values range is from 0 to 9. We use zero as terminator, so we'll add 1 to the value.

searchPatterns ( char word, int index, sbyte il ) : void

Search for all possible partial matches of word starting at index an update interletter values. In other words, it does something like:

for(i=0; i<patterns.length; i++) { if ( word.substring(index).startsWidth(patterns[i]) ) update_interletter_values(patterns[i]); }

But it is done in an efficient way since the patterns are stored in a ternary tree. In fact, this is the whole purpose of having the tree: doing this search without having to test every single pattern. The number of patterns for languages such as English range from 4000 to 10000. Thus, doing thousands of string comparisons for each word to hyphenate would be really slow without the tree. The tradeoff is memory, but using a ternary tree instead of a trie, almost halves the the memory used by Lout or TeX. It's also faster than using a hash table

unpackValues ( int k ) : string

메소드 상세

HyphenationTree() 공개 메소드

public HyphenationTree ( ) : System
리턴 System

addClass() 공개 메소드

Add a character class to the tree. It is used by PatternParser PatternParser as callback to add character classes. Character classes define the valid word characters for hyphenation. If a word contains a character not defined in any of the classes, it is not hyphenated. It also defines a way to normalize the characters in order to compare them with the stored patterns. Usually pattern files use only lower case characters, in this case a class for letter 'a', for example, should be defined as "aA", the first character being the normalization char.
public addClass ( string chargroup ) : void
chargroup string
리턴 void

addException() 공개 메소드

Add an exception to the tree. It is used by PatternParser PatternParser class as callback to store the hyphenation exceptions.
public addException ( string word, List hyphenatedword ) : void
word string normalized word
hyphenatedword List a vector of alternating strings and /// objects.
리턴 void

addPattern() 공개 메소드

Add a pattern to the tree. Mainly, to be used by PatternParser PatternParser class as callback to add a pattern to the tree.
public addPattern ( string pattern, string ivalue ) : void
pattern string the hyphenation pattern
ivalue string interletter weight values indicating the desirability and /// priority of hyphenating at a given point within the pattern. It /// should contain only digit characters. (i.e. '0' to '9').
리턴 void

findPattern() 공개 메소드

public findPattern ( string pat ) : string
pat string
리턴 string

getValues() 보호된 메소드

protected getValues ( int k ) : sbyte[]
k int
리턴 sbyte[]

hstrcmp() 보호된 메소드

String compare, returns 0 if equal or t is a substring of s
protected hstrcmp ( char s, int si, char t, int ti ) : int
s char
si int
t char
ti int
리턴 int

hyphenate() 공개 메소드

Hyphenate word and return an array of hyphenation points.
public hyphenate ( char w, int offset, int len, int remainCharCount, int pushCharCount ) : Hyphenation
w char char array that contains the word
offset int Offset to first character in word
len int Length of word
remainCharCount int Minimum number of characters allowed before the /// hyphenation point.
pushCharCount int Minimum number of characters allowed after the /// hyphenation point.
리턴 Hyphenation

hyphenate() 공개 메소드

Hyphenate word and return a Hyphenation object.
public hyphenate ( string word, int remainCharCount, int pushCharCount ) : Hyphenation
word string the word to be hyphenated
remainCharCount int Minimum number of characters allowed before the /// hyphenation point.
pushCharCount int Minimum number of characters allowed after the /// hyphenation point.
리턴 Hyphenation

loadPatterns() 공개 메소드

Read hyphenation patterns from an XML file.
In case the parsing fails
public loadPatterns ( File f ) : void
f File the filename
리턴 void

loadPatterns() 공개 메소드

Read hyphenation patterns from an XML file.
In case the parsing fails
public loadPatterns ( InputSource source ) : void
source InputSource the InputSource for the file
리턴 void

packValues() 보호된 메소드

Packs the values by storing them in 4 bits, two values into a byte Values range is from 0 to 9. We use zero as terminator, so we'll add 1 to the value.
protected packValues ( string values ) : int
values string a string of digits from '0' to '9' representing the /// interletter values.
리턴 int

printStats() 공개 메소드

public printStats ( PrintStream @out ) : void
@out PrintStream
리턴 void

searchPatterns() 보호된 메소드

Search for all possible partial matches of word starting at index an update interletter values. In other words, it does something like:

for(i=0; i<patterns.length; i++) { if ( word.substring(index).startsWidth(patterns[i]) ) update_interletter_values(patterns[i]); }

But it is done in an efficient way since the patterns are stored in a ternary tree. In fact, this is the whole purpose of having the tree: doing this search without having to test every single pattern. The number of patterns for languages such as English range from 4000 to 10000. Thus, doing thousands of string comparisons for each word to hyphenate would be really slow without the tree. The tradeoff is memory, but using a ternary tree instead of a trie, almost halves the the memory used by Lout or TeX. It's also faster than using a hash table

protected searchPatterns ( char word, int index, sbyte il ) : void
word char null terminated word to match
index int start index from word
il sbyte interletter values array to update
리턴 void

unpackValues() 보호된 메소드

protected unpackValues ( int k ) : string
k int
리턴 string

프로퍼티 상세

classmap 보호되어 있는 프로퍼티

This map stores the character classes
protected TernaryTree classmap
리턴 TernaryTree

stoplist 보호되어 있는 프로퍼티

This map stores hyphenation exceptions
protected Dictionary> stoplist
리턴 List>.Dictionary

vspace 보호되어 있는 프로퍼티

value space: stores the interletter values
protected ByteVector,org.apache.lucene.analysis.compound.hyphenation vspace
리턴 ByteVector