private static void AppendSymbolPattern(StringBuilder sb, string name, SymbolCollection symbols) { if (symbols.Count > 0) { if (sb.Length > 0) { sb.Append("|"); } sb.AppendFormat("(?'{0}'{1})", name, CreateSymbolRegexString(symbols)); } }
public Segmenter() { _vowels = new SymbolCollection(); _vowels.CollectionChanged += SymbolCollectionChanged; _consonants = new SymbolCollection(); _consonants.CollectionChanged += SymbolCollectionChanged; _modifiers = new SymbolCollection(); _modifiers.CollectionChanged += SymbolCollectionChanged; _joiners = new SymbolCollection(); _joiners.CollectionChanged += SymbolCollectionChanged; _toneLetters = new SymbolCollection(); _toneLetters.CollectionChanged += SymbolCollectionChanged; _boundaries = new SymbolCollection(); _boundaries.CollectionChanged += SymbolCollectionChanged; _emptyShape = new Shape(begin => new ShapeNode(FeatureStruct.New().Symbol(CogFeatureSystem.AnchorType).Feature(CogFeatureSystem.StrRep).EqualTo("#").Value)); _emptyShape.Freeze(); }
private bool TryMultipleBaseCharacterSymbol(Match match, SymbolCollection bases, out string strRep, out FeatureStruct fs) { Group joinerGroup = match.Groups["joiner"]; Group modGroup = match.Groups["mod"]; Group consBaseGroup = match.Groups["consBase"]; Symbol symbol; if (joinerGroup.Success && (!modGroup.Success || modGroup.Index >= consBaseGroup.Index + consBaseGroup.Length) && bases.TryGet(string.Concat(consBaseGroup.Captures.Cast <Capture>().Select(cap => cap.Value)), out symbol)) { var sb = new StringBuilder(); sb.Append(symbol.StrRep); fs = symbol.FeatureStruct != null?symbol.FeatureStruct.Clone() : new FeatureStruct(); ApplyModifiers(match.Groups["mod"].Captures.Cast <Capture>(), sb, fs); strRep = sb.ToString(); return(true); } strRep = null; fs = null; return(false); }
private FeatureStruct BuildFeatStruct(Match match, Capture capture, string baseGroupName, SymbolCollection bases, out string strRep) { string baseStr = match.Groups[baseGroupName].Captures.Cast <Capture>().Single(cap => capture.Index == cap.Index).Value.ToLowerInvariant(); FeatureStruct baseFs = bases[baseStr].FeatureStruct; FeatureStruct fs = baseFs != null?baseFs.Clone() : new FeatureStruct(); var sb = new StringBuilder(); sb.Append(baseStr); ApplyModifiers(match.Groups["mod"].Captures.Cast <Capture>().Where(cap => capture.Index <= cap.Index && (capture.Index + capture.Length) >= (cap.Index + cap.Length)), sb, fs); strRep = sb.ToString(); return(fs); }