private bool MergeEnglishSpecialWord(string orginalText, SuperLinkedList<WordInfo> wordInfoList, ref SuperLinkedListNode<WordInfo> current)
{
SuperLinkedListNode<WordInfo> cur = current;
cur = cur.Next;
int last = -1;
while (cur != null)
{
if (cur.Value.WordType == WordType.Symbol || cur.Value.WordType == WordType.English)
{
last = cur.Value.Position + cur.Value.Word.Length;
cur = cur.Next;
}
else
{
break;
}
}
if (last >= 0)
{
int first = current.Value.Position;
string newWord = orginalText.Substring(first, last - first);
WordAttribute wa = _WordDictionary.GetWordAttr(newWord);
if (wa == null)
{
return false;
}
while (current != cur)
{
SuperLinkedListNode<WordInfo> removeItem = current;
current = current.Next;
wordInfoList.Remove(removeItem);
}
WordInfo newWordInfo = new WordInfo(new PanGu.Dict.PositionLength(first, last - first,
wa), orginalText, _Parameters);
newWordInfo.WordType = WordType.English;
newWordInfo.Rank = _Parameters.EnglishRank;
if (_Options.EnglishSegment)
{
string lowerWord = newWordInfo.Word.ToLower();
if (lowerWord != newWordInfo.Word)
{
if (current == null)
{
wordInfoList.AddLast(newWordInfo);
}
else
{
wordInfoList.AddBefore(current, newWordInfo);
}
}
newWordInfo = new WordInfo(lowerWord, newWordInfo.Position, newWordInfo.Pos, newWordInfo.Frequency, _Parameters.EnglishLowerRank, newWordInfo.WordType,
newWordInfo.OriginalWordType);
}
else if (_Options.IgnoreCapital)
{
newWordInfo.Word = newWordInfo.Word.ToLower();
}
if (current == null)
{
wordInfoList.AddLast(newWordInfo);
}
else
{
wordInfoList.AddBefore(current, newWordInfo);
}
return true;
}
return false;
}