示例#1
0
        private void AnalyzeText(
            string value,
            int startIndex,
            int length,
            ref ImmutableArray <SpellingMatch> .Builder builder)
        {
            int sequenceEndIndex = -1;

            for (
                Match match = WordRegex.Match(value, startIndex, length);
                match.Success;
                match = match.NextMatch())
            {
                if (sequenceEndIndex >= 0)
                {
                    if (match.Index <= sequenceEndIndex)
                    {
                        continue;
                    }
                    else
                    {
                        sequenceEndIndex = -1;
                    }
                }

                WordSequenceMatch sequenceMatch = Data.GetSequenceMatch(value, startIndex, length, match);

                if (!sequenceMatch.IsDefault)
                {
                    sequenceEndIndex = sequenceMatch.EndIndex;
                    continue;
                }

                if (match.Length >= Options.MinWordLength)
                {
                    if (_splitRegex == null)
                    {
                        AnalyzeValue(match.Value, match.Index, null, 0, ref builder);
                    }
                    else
                    {
                        AnalyzeSplit(_splitRegex, match.Value, match.Index, 0, ref builder);
                    }
                }
            }
        }
示例#2
0
        public WordSequenceMatch GetSequenceMatch(string value, int startIndex, int length, Match match)
        {
            if (CaseSensitiveWords.Sequences.TryGetValue(match.Value, out ImmutableArray <WordSequence> sequences))
            {
                WordSequenceMatch sequenceMatch = GetSequenceMatch(value, startIndex, length, match, sequences, Words.Comparison);

                if (!sequenceMatch.IsDefault)
                {
                    return(sequenceMatch);
                }
            }

            if (Words.Sequences.TryGetValue(match.Value, out sequences))
            {
                return(GetSequenceMatch(value, startIndex, length, match, sequences, Words.Comparison));
            }

            return(default);