示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SynonymFinderBase"/> class.
        /// </summary>
        protected SynonymFinderBase()
        {
            var Data  = new FileInfo($"resource://Enlighten/Enlighten.Resources.{Name.Replace("-", "_", StringComparison.Ordinal)}.synonyms.txt").Read();
            var Lines = Data.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0, LinesLength = Lines.Length; i < LinesLength; i++)
            {
                var Line = Lines[i];
                if (string.IsNullOrEmpty(Line))
                {
                    continue;
                }
                var LineData = Line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                for (int x = 1; x < LineData.Length; ++x)
                {
                    SynonymDictionary.Add(LineData[x], LineData[0]);
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        if (!runSynonymDictionaryTests)
        {
            return;
        }
        //Debug.Log(Application.persistentDataPath);

        Debug.Log(SynonymDictionary.DictionaryAsString()); //prints out current dictionary

        Debug.Log("-----Loaded currently saved dictionary-----");
        if (SynonymDictionary.LoadSynonymDictionary())
        {
            Debug.Log("  ---Found a saved file---");
        }
        else
        {
            Debug.Log("  ---Created new save file---");
        }
        Debug.Log(SynonymDictionary.DictionaryAsString());



        SynonymDictionary.Add("starcraft2 races", new List <string>()
        {
            "zerg", "terran", "protoss"
        });
        SynonymDictionary.Add("LoL Roles", new List <string>()
        {
            "ADC", "Mid", "Top", "Jungle", "Support"
        });
        Debug.Log("-----Added test string/List<string> to dictionary-----");
        Debug.Log(SynonymDictionary.DictionaryAsString()); //prints out current dictionary after adding tests


        SynonymDictionary.SaveSynonymDictionary();
        Debug.Log("-----Saved current dictionary-----");
        Debug.Log(SynonymDictionary.DictionaryAsString());
    }