コード例 #1
0
    //-----------------------------------------------------------------------------
    public bool CheckValidWord(string theWord)
    {
        theWord = theWord.ToLower();

        // check for 2 letter word first (not long enough for 3 prefix list)
        if (theWord.Length < 2)
        {
            return(false);
        }
        if (theWord.Length == 2)
        {
            return(WordList.OtherWordList.IndexOf(theWord) != -1);
        }

        // get the first three letters to look up in our dictionary
        var first3 = Regex.Replace(theWord, "^(...).*", "$1");

        // are these first three letters in our table?
        string theEntry = "";
        var    found    = WordList.ThreeLetterPrefixWordList.TryGetValue(first3, out theEntry);

        if (!found)
        {
            return(false);
        }

        theEntry = WordList.DecompressString(theEntry, first3);

        // remove trailing and leading comma
        //theEntry = theEntry.Remove(0, 1);
        //theEntry = theEntry.Remove(theEntry.Length - 1, 1);

        var restOfWord = Regex.Replace(theWord, "^...?", "");
        var valid      = (theEntry.IndexOf("," + restOfWord + ",") != -1);

        Debug.Log("Saying " + theWord + " is valid? " + valid + " " + theEntry);
        return(valid);
    }