示例#1
0
 public Syllable(Syllable syllableToCopy)
 {
     foreach (Phoneme phoneme in syllableToCopy)
     {
         Add(phoneme);
     }
 }
示例#2
0
        public Word ConstructWord(Random rng)
        {
            Word word = new Word();

            /*
             * int syllableCount = WordLengths.SelectRandom();
             *
             * if (syllableCount == 1)
             * {
             *  Syllable syllable = new Syllable();
             *  int attempts = 0;
             *  do
             *  {
             *      syllable.Clear();
             *      syllable = ConstructSyllable(rng, true, true);
             *      attempts++;
             *  }
             *  while (syllable.Count < 2 && attempts < 10);
             *  word.Add(syllable);
             * }
             * else
             * {
             *  for (int i = 1; i <= syllableCount; i++)
             *  {
             *      Syllable syllable = ConstructSyllable(rng, (i == 1), (i == syllableCount));
             *
             *      if (syllable.Count > 0)
             *          word.Add(syllable);
             *  }
             * }
             */

            int length = WordLengths.SelectRandom();

            bool isFirst = true;

            do
            {
                Syllable final = ConstructSyllable(rng, isFirst, true);

                if (word.TotalLength + final.Count >= length)
                {
                    word.Add(final);
                }
                else
                {
                    Syllable nonFinal = ConstructSyllable(rng, isFirst, false);

                    word.Add(nonFinal);
                }
                isFirst = false;
            }while (word.TotalLength < length);

            return(word);// RemoveForbiddenElements(word);
        }
示例#3
0
        /*
         * private Word RemoveForbiddenElements(Word word)
         * {
         *  for (int syllableIndex = 0; syllableIndex < word.Count; syllableIndex++)
         *  {
         *      Syllable currentSyllable = word[syllableIndex];
         *      Syllable nextSyllable = null;
         *      if (syllableIndex + 1 < word.Count)
         *          nextSyllable = word[syllableIndex + 1];
         *
         *      Syllable newSyllable = new Syllable(currentSyllable);
         *      for (int phonemeIndex = 0; phonemeIndex < currentSyllable.Count; phonemeIndex++)
         *      {
         *          Phoneme currentPhoneme = currentSyllable[phonemeIndex];
         *
         *          if (currentPhoneme is Consonant)
         *              if (nextSyllable != null && phonemeIndex == currentSyllable.Count - 1)
         *                  if (currentPhoneme == nextSyllable[0])
         *                      if (Geminates == Phonotactics.Forbidden)
         *                      {
         *                          newSyllable.Remove(currentPhoneme);
         *                      }
         *      }
         *
         *      word[syllableIndex] = newSyllable;
         *  }
         *
         *  return word;
         * }
         */

        public Word ConstructLoanword(Word wordToLoan)
        {
            Word newWord = new Word();

            foreach (Syllable syllable in wordToLoan)
            {
                Syllable newSyllable = new Syllable();

                foreach (Phoneme phoneme in syllable)
                {
                    newSyllable.Add(SelectClosestPhoneme(phoneme));
                }

                newWord.Add(newSyllable);
            }

            return(newWord);
        }
示例#4
0
        private Syllable ConstructSyllable(Random rng, bool isInitial, bool isFinal)
        {
            Syllable syllable = new Syllable();

            if (isInitial)
            {
                if (rng.NextDouble() < WordInitialOnsetChance)
                {
                    syllable.Add(Onsets.SelectRandom());
                }
            }
            else
            {
                if (rng.NextDouble() < WordMedialOnsetChance)
                {
                    syllable.Add(Onsets.SelectRandom());
                }
            }

            if (rng.NextDouble() < NucleusChance)
            {
                syllable.Add(Nuclei.SelectRandom());
            }

            if (isFinal)
            {
                if (rng.NextDouble() < WordFinalCodaChance)
                {
                    syllable.Add(Codae.SelectRandom());
                }
            }
            else
            {
                if (rng.NextDouble() < WordMedialCodaChance)
                {
                    syllable.Add(Codae.SelectRandom());
                }
            }

            return(syllable);
        }