initial commit

This commit is contained in:
2019-11-30 10:38:38 +00:00
commit d6727ddad1
14 changed files with 55379 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
plugins {
kotlin("jvm")
application
}
group = "woggioni.net"
version = "0.1"
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
compile(rootProject)
// runtime(files(rootProject.projectDir.toPath().resolve("src/test/resources")))
}
application {
mainClassName = "net.woggioni.klevtree.benchmark.BenchmarkKt"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

View File

@@ -0,0 +1 @@
rootProject.name = "klevtree-benchmark"

View File

@@ -0,0 +1,43 @@
package net.woggioni.klevtree.benchmark
import net.woggioni.klevtree.ILevTrie
import net.woggioni.klevtree.LevTrie
import java.io.BufferedReader
import java.io.InputStreamReader
import net.woggioni.jwo.Chronometer
fun main(args: Array<String>) {
val reader = BufferedReader(
InputStreamReader(Chronometer::class.java.getResourceAsStream("/cracklib-small"))
)
val tree = LevTrie()
tree.caseSensitive = false
try {
for(line in reader.lines()) {
tree.add(line.asIterable())
}
} finally {
reader.close()
}
tree.algorithm = ILevTrie.Algorithm.DAMERAU_LEVENSHTEIN
tree.caseSensitive = false
val chr = Chronometer()
val keys = arrayOf("camel", "coriolis", "mattel", "cruzer", "cpoper", "roublesoot")
for (ind in 0 until 50) {
for (searchKey in keys) {
tree.fuzzySearch(searchKey, 6)
}
}
for (searchKey in keys) {
val standing = tree.fuzzySearch(searchKey, 6)
for (res in standing) {
println("distance: ${res.second}\t wordkey: ${res.first}")
}
println()
}
System.out.printf("Elapsed time: %.3f s\n", chr.elapsed(Chronometer.UnitOfMeasure.SECONDS))
println("++++++++++++ End benchmark ++++++++++++")
}

File diff suppressed because it is too large Load Diff