Rename CedictParserImpl to RegexCedictParser

This commit is contained in:
Marvin Elsen 2024-09-24 10:36:49 +02:00
parent 200cd7d06b
commit 9d3f1ec456
Signed by: marvinelsen
GPG Key ID: 820672408CC318C2
3 changed files with 5 additions and 5 deletions

View File

@ -1,12 +1,12 @@
package com.marvinelsen.cedict.api
import com.marvinelsen.cedict.internal.CedictParserImpl
import com.marvinelsen.cedict.internal.RegexCedictParser
import java.io.InputStream
interface CedictParser {
fun parseCedict(inputStream: InputStream): Sequence<CedictEntry>
companion object {
val instance: CedictParser by lazy { CedictParserImpl() }
val instance: CedictParser by lazy { RegexCedictParser() }
}
}

View File

@ -6,7 +6,7 @@ import com.marvinelsen.cedict.api.CedictParser
import com.marvinelsen.chinese.transliteration.Syllable
import java.io.InputStream
internal class CedictParserImpl : CedictParser {
internal class RegexCedictParser : CedictParser {
companion object {
private const val DEFINITION_SEPARATOR = '/'
private const val GLOSS_SEPARATOR = ';'

View File

@ -9,7 +9,7 @@ import java.util.zip.GZIPInputStream
class CedictParserImplTest : ShouldSpec({
should("parse lines correctly") {
val cedictParser = CedictParserImpl()
val cedictParser = RegexCedictParser()
val cedictEntry =
cedictParser.toCedictEntry("皮實 皮实 [pi2 shi5] /(of things) durable/(of people) sturdy; tough/")
@ -29,7 +29,7 @@ class CedictParserImplTest : ShouldSpec({
val cedictFilePath = "/cedict_1_0_ts_utf-8_mdbg.txt.gz"
val cedictFileStream = GZIPInputStream(javaClass.getResourceAsStream(cedictFilePath))
val cedictParser = CedictParserImpl()
val cedictParser = RegexCedictParser()
val cedictEntries = cedictParser.parseCedict(cedictFileStream)
cedictEntries.toList().size shouldBe 122_508