джерело
f1f4f7d766
коміт
0fb2d1019f
@ -0,0 +1,31 @@ |
||||
/** |
||||
* Created with IntelliJ IDEA. |
||||
* User: jcd |
||||
* Date: 4/26/13 |
||||
* Time: 11:04 AM |
||||
*/ |
||||
class Word (val lentgh:Int){ |
||||
var numOfN = 0 |
||||
var numOfYouon = 0 |
||||
var numOfFSyllables = 0 |
||||
var numOfVSyllables = 0 |
||||
private val value:StringBuilder = new StringBuilder() |
||||
def append(syllable:Syllable){ |
||||
value.append(syllable.toString) |
||||
} |
||||
override def toString:String = { |
||||
value.toString() |
||||
} |
||||
def n():Int = { |
||||
numOfN / lentgh * 100 |
||||
} |
||||
def youyon():Int = { |
||||
numOfYouon / lentgh * 100 |
||||
} |
||||
def fsyl():Int = { |
||||
numOfFSyllables / lentgh * 100 |
||||
} |
||||
def vsyl():Int = { |
||||
numOfVSyllables / lentgh * 100 |
||||
} |
||||
} |
@ -0,0 +1,25 @@ |
||||
/** |
||||
* Created with IntelliJ IDEA. |
||||
* User: jcd |
||||
* Date: 4/26/13 |
||||
* Time: 11:03 AM |
||||
*/ |
||||
class WordGenerator(val sg:SyllableGenerator) { |
||||
def generateWord:Word= { |
||||
val word = new Word(Randomizer.pickInt(3,6)) |
||||
var lastYouon = false |
||||
for (i <- 0 to word.lentgh){ |
||||
val syllable = |
||||
if ((0 to 5 contains(word.n())) && Randomizer.pickWithProb(0.25)){ |
||||
sg.generateSyllableV(useN = true) |
||||
} else if ((0 to 25 contains(word.vsyl())) && Randomizer.pickWithProb(0.49)){ |
||||
sg.generateSyllableV(useN = false) |
||||
} else { |
||||
sg.generateSyllableF(youonForce = false, youonProhibit = lastYouon) |
||||
} |
||||
lastYouon = syllable.isYouon |
||||
word.append(syllable) |
||||
} |
||||
word |
||||
} |
||||
} |
Завантаження…
Посилання в новій задачі