Skip to content

Commit

Permalink
measure decoding time
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Apr 27, 2024
1 parent f4c338a commit 1d1882b
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ class WFSATest {
@Test
fun testLBHRepair() {
val toRepair = "NAME : NEWLINE NAME = STRING NEWLINE NAME = NAME . NAME ( STRING ) NEWLINE"
Grammars.seq2parsePythonCFG.makeLevPTree(toRepair, 2)
.propagator<Automaton<String, Double>>(
val pt = Grammars.seq2parsePythonCFG.makeLevPTree(toRepair, 2)
measureTimedValue {
pt.propagator<Automaton<String, Double>>(
both = { a, b -> if (a == null) b else if (b == null) a else Concatenation(a, b) },
either = { a, b -> if (a == null) b else if (b == null) a else Union(a, b) },
unit = { a ->
Expand All @@ -50,9 +51,10 @@ class WFSATest {
val s2 = addState(0.0, 1.0)
addTransition(s1, s2, a.root, 1.0)
}
}
}
).also { println("Total: ${Automata.transitions(it).size} arcs, ${Automata.states(it).size}") }
.let { Automata.bestStrings(it, 1000).map { it.label.joinToString(" ") } }
.forEach { println(levenshteinAlign(toRepair, it).paintANSIColors()) }
}.also { it.value.forEach { println(levenshteinAlign(toRepair, it).paintANSIColors()) } }
.also { println("Decoding ${it.value.size} repairs took ${it.duration}") }
}
}

0 comments on commit 1d1882b

Please sign in to comment.