public float SearchHanzi(StringPointer hanzi) { float strActualLength = hanzi.ActualLength; float relevance = 0; foreach (string chineseSearchWord in ChineseSearchWords) { StringSearch.Result result; // check if the word (AB) is part of the search (ABC) result = StringSearch.Search(hanzi, chineseSearchWord, 0, chineseSearchWord.Length, HanziSearchFlags); if (result.Found) { // in this case, order the results based on character order in the word relevance += 4 - (float)result.Start / chineseSearchWord.Length; } // check if the word (AB) contains our search (A) result = StringSearch.Search(chineseSearchWord, 0, chineseSearchWord.Length, hanzi, HanziSearchFlags); if (result.Found) { relevance += 2 * (float)chineseSearchWord.Length / hanzi.ActualLength; } } return(relevance); }
public bool Equals(StringPointer other) { if (Length == other.Length) { return(StringSearch.Search(this, other, SearchFlags.IGNORE_CASE | SearchFlags.IGNORE_DIACRITICS).Found&& StringSearch.Search(other, this, SearchFlags.IGNORE_CASE | SearchFlags.IGNORE_DIACRITICS).Found); //return string.Compare(WordDictionary.StringMemory, Start, WordDictionary.StringMemory, other.Start, Length) == 0; } else { return(false); } }