Beispiel #1
0
    public static void Main(string[] args)
    {
        // build up a very simple vowel inventory
        // make sure features are within simple set in Inventory's place/manner/voicing
        Inventory inventory = new Inventory();

        inventory.AddConsonant("b", "voiced", "bilabial", "plosive");
        inventory.AddConsonant("p", "voiceless", "bilabial", "plosive");
        inventory.AddConsonant("g", "voiced", "velar", "plosive");
        inventory.AddConsonant("k", "voiceless", "velar", "plosive");
        inventory.AddConsonant("d", "voiced", "dental", "plosive");
        inventory.AddConsonant("t", "voiceless", "dental", "plosive");
        inventory.AddConsonant("h", "voiceless", "glottal", "fricative");
        inventory.AddConsonant("l", "voiced", "alveolar", "lateral");
        inventory.AddConsonant("r", "voiced", "alveolar", "approximant");
        inventory.AddConsonant("w", "voiced", "velar", "approximant");
        // build up very simple consonant inventory
        // make sure features are within simple set in Inventory's height/backness/rounding
        inventory.AddVowel("i", "close", "front", "unrounded");
        inventory.AddVowel("a", "open", "central", "unrounded");
        inventory.AddVowel("u", "close", "back", "rounded");

        // recall features using any letter
        Debug.Log(inventory.GetFeatures("b"));

        // This finds "b":
        List <string> testFeaturesList = new List <string> {
            "voiced", "bilabial", "plosive"
        };

        inventory.GetLetter(testFeaturesList);
        // This will not find "b":
        testFeaturesList [0] = "bilabial";
        testFeaturesList [1] = "voiced";
        inventory.GetLetter(testFeaturesList);

        Syllable syllableStructure = new Syllable();

        syllableStructure.AddStructure(new List <string> {
            "C", "V"
        });
        syllableStructure.AddStructure(new List <string> {
            "C", "V", "V"
        });
        syllableStructure.AddStructure(new List <string> {
            "C", "V", "C"
        });
        syllableStructure.AddStructure(new List <string> {
            "C", "V", "V", "C"
        });

        Rules rules = new Rules();

        rules.AddRule("voiced", "voiceless", "_ voiceless");

        Affixes affixes = new Affixes();

        // add prefixes and suffixes
        // trusts you to use only characters found in inventory (matters for rule application)
        affixes.AddAffix("human", "-", "g", "u", "d");
        affixes.AddAffix("nonhuman", "-", "i", "d");
        affixes.AddAffix("strong", "t", "-");
        affixes.AddAffix("small", "l", "-");
        affixes.AddAffix("strange", "g", "-");

        // TODO structure language
        Language language = new Language(inventory, syllableStructure, rules, affixes);

        // build a long proper noun
        List <string> properNoun = language.BuildWord(3, true, "strong", "nonhuman");

        Debug.Log(string.Join("", properNoun.ToArray()));

        // build a short regular noun
        List <string> justSomeNoun = language.BuildWord(2);

        // add both to the dictionary
        language.AddEntry(properNoun, "Wolf");
        language.AddEntry(justSomeNoun, "food");
        Debug.Log(language.PrintDictionary());
    }