handloose make action arrows
This commit is contained in:
@@ -1,30 +1,34 @@
|
||||
(defNew [&prop :String path]
|
||||
(type "") // If the file can't be written to, throw the error right away
|
||||
// Use files with the same extension in the current working directory to determine letter frequencies
|
||||
(walkDirectory (FileSystem.absolutePath "")
|
||||
->file (when (= (file.extension) (path.extension))
|
||||
(learnFrequencies (File.getContent file)))))
|
||||
(walkDirectory "" (FileSystem.absolutePath "")
|
||||
->file (when (= (Path.extension file) (Path.extension path))
|
||||
(learnFrequencies ~(File.getContent ~file))
|
||||
~charFrequencies)))
|
||||
|
||||
(prop &mut :String content "")
|
||||
(method type [:String str]
|
||||
(method :Void type [:String str]
|
||||
(+= content str)
|
||||
(File.saveContent path content))
|
||||
(File.saveContent path content)
|
||||
(print content))
|
||||
|
||||
(prop :Map<String,Map<String,Int>> charFrequencies (new Map))
|
||||
(prop :Map<String,Map<String,Int>> wordFrequencies (new Map))
|
||||
|
||||
(method incFrequency [:Map<String,Map<String,Int>> m :String c :String following]
|
||||
(unless (m.exists following) (dictSet m following (new Map)))
|
||||
(let [followingMap (dictGet m following)]
|
||||
(dictSet followingMap c (+ 1 (or (dictGet followingMap c) 0)))))
|
||||
(when c
|
||||
(unless (m.exists following) (dictSet m following (new Map)))
|
||||
(let [followingMap (dictGet m following)]
|
||||
(dictSet followingMap c (+ 1 (or (dictGet followingMap c) 0))))))
|
||||
|
||||
(method learnFrequencies [:String str]
|
||||
(let [chars (str.split "")]
|
||||
(incFrequency charFrequencies (first chars) "")
|
||||
(doFor [following c] (pairs chars)
|
||||
(incFrequency charFrequencies c following)))
|
||||
// TODO learn word frequencies
|
||||
)
|
||||
(when chars
|
||||
(incFrequency charFrequencies (first chars) "")
|
||||
(doFor [following c] (pairs chars)
|
||||
(incFrequency charFrequencies c following)))
|
||||
// TODO learn word frequencies
|
||||
))
|
||||
|
||||
(prop :FlxRandom r (new FlxRandom))
|
||||
(method :ArrowStuff generateArrowStuff []
|
||||
@@ -32,7 +36,7 @@
|
||||
(let [lastChar (substr content -1)
|
||||
charFreq (dictGet charFrequencies lastChar)
|
||||
chars []
|
||||
weights []]
|
||||
:Array<Float> weights []]
|
||||
(doFor =>c weight charFreq
|
||||
(chars.push c)
|
||||
(weights.push weight))
|
||||
|
Reference in New Issue
Block a user