Save fuzzy matches

This commit is contained in:
2023-04-18 16:40:31 -06:00
parent d788b70fec
commit e43ab264df
2 changed files with 15 additions and 2 deletions

View File

@@ -54,7 +54,18 @@
// When an actorName is given, check for a voiced line to play.
// Otherwise, assume it is un-voiced super text
(when (and actorName (< 0 (count voiceTracks)))
(case (try (dictGet (dictGet voiceLines actorName) text) (catch [e] (print e) null))
(case
(let [voiceLineKey
(if (voiceLineMatches.exists text)
.value (voiceLineMatches.get text)
(FuzzyMapTools.bestMatch (dictGet voiceLines actorName) text false))]
(if voiceLineKey
{
(#when debug
(voiceLineMatches.put text (new JsonableString voiceLineKey)))
(dictGet (dictGet voiceLines actorName) voiceLineKey)
}
null))
((objectWith trackKey start end alts)
(case (dictGet altIdx "$actorName $text")
(null
@@ -88,7 +99,7 @@
(if line.alts
(for alt (the Array<Dynamic> line.alts) (objectWith [start alt.start end alt.end] trackKey))
[])]
(unless (voiceLines.exists actorName)
(unless (voiceLines.existsExactly actorName)
(dictSet voiceLines actorName (new FuzzyMap<VoiceLine>)))
(dictSet (dictGet voiceLines actorName) key (objectWith [start line.start end line.end] trackKey alts))))))

View File

@@ -26,3 +26,5 @@
(put key defaultVal))
(dictGet m key))
(method exists [:String key]
(m.exists key))