public HyphenationTokenFilter(TokenStream input, Hyphenator hyphenator) : base(input) { _hyphenator = hyphenator; _termAtt = (TermAttribute)AddAttribute(typeof(TermAttribute)); _typeAtt = (TypeAttribute)AddAttribute(typeof(TypeAttribute)); _ofsAtt = (OffsetAttribute)AddAttribute(typeof(OffsetAttribute)); }
public Hyphenator Read(XDocument document) { if (document == null || document.Root == null) throw new ArgumentException("Invalid document supplied.", "document"); var hyphenator = new Hyphenator(); var minMax = document.Root.Element("hyphen-min"); hyphenator.MinimumPrefix = int.Parse(GetValue(minMax, "before", "2")); hyphenator.MinimumSuffix = int.Parse(GetValue(minMax, "after", "2")); hyphenator.Patterns = ReadPatterns(document.Root.Element("patterns")).ToList(); return hyphenator; }
public override Hyphenator Load(TextReader source) { if (source == null) throw new ArgumentNullException("source"); string line; bool started = false; var patterns = new List<HyphenatorPattern>(); while((line = source.ReadLine()) != null) { if (!started && line.StartsWith("charset ")) continue; // no support for charset for now. if(string.IsNullOrWhiteSpace(line)) continue; started = true; patterns.Add(new HyphenatorPattern(line)); } var hyphenator = new Hyphenator(); hyphenator.MinimumPrefix = 2; hyphenator.MinimumSuffix = 2; hyphenator.Patterns = patterns; return hyphenator; }