Skip to content

Commit

Permalink
fix: builder
Browse files Browse the repository at this point in the history
  • Loading branch information
borgoat committed May 5, 2022
1 parent e59e85e commit 4c49b71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/main/kotlin/com/github/borgoat/markovaldo/MarkovChain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ class MarkovChain(
val tokenState = ArrayDeque<Token>()
tokens.forEach {
if (tokenState.isNotEmpty()) {
val innerMap = probs.getOrPut(tokenState) { mutableMapOf() }
val innerMap = probs.getOrPut(tokenState.takeLast(order)) { mutableMapOf() }
innerMap.getOrPut(it) { AtomicLong(0) }.incrementAndGet()
}

tokenState.add(it)
if (tokenState.count() > order) tokenState.removeFirst()
}
}

Expand Down

0 comments on commit 4c49b71

Please sign in to comment.