Skip to content

Commit

Permalink
test Pasti et al.'s modified Bar-Hillel construction
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Oct 1, 2023
1 parent fecf725 commit 94a660a
Show file tree
Hide file tree
Showing 4 changed files with 645 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ fun CFG.normalize(): CFG =
}

fun CFG.transformIntoCNF(): CFG =
addEpsilonProduction()
.refactorEpsilonProds()
.elimVarUnitProds()
// addEpsilonProduction()
// .refactorEpsilonProds()
elimVarUnitProds()
.refactorRHS()
.terminalsToUnitProds()
.removeUselessSymbols()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PTree(val root: String = "ε", val branches: List<Π2A<PTree>> = listOf())
// Lazily computes all syntactically strings compatible with the given template
fun CFG.solveSeq(s: String): Sequence<String> =
initPForestMat(s.tokenizeByWhitespace()).seekFixpoint()
.diagonals.last()[0][START_SYMBOL]?.choose() ?: emptySequence()
.diagonals.last()[0][START_SYMBOL]?.choose()?.distinct() ?: emptySequence()

fun CFG.initPForestMat(tokens: List<String>): UTMatrix<PForest> =
UTMatrix(
Expand Down
Loading

0 comments on commit 94a660a

Please sign in to comment.