예제 #1
0
        protected AnnotatedStringData CreateStringData(string str)
        {
            var stringData = new AnnotatedStringData(SpanFactory, str);

            for (int i = 0; i < str.Length; i++)
            {
                FeatureStruct fs = Characters[str[i]];
                stringData.Annotations.Add(i, i + 1, fs.DeepClone());
            }
            return(stringData);
        }
예제 #2
0
        internal override State <TData, TOffset> GenerateNfa(Fst <TData, TOffset> fsa, State <TData, TOffset> startState, out bool hasVariables)
        {
            hasVariables = _fs.HasVariables;
            FeatureStruct condition = _fs;

            if (!_fs.IsFrozen)
            {
                condition = _fs.DeepClone();
                condition.Freeze();
            }
            return(startState.Arcs.Add(condition, fsa.CreateState()));
        }
예제 #3
0
파일: Segmenter.cs 프로젝트: megahirt/cog
        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.DeepClone() : 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);
        }