Skip to content

Commit

Permalink
Add Estonian language
Browse files Browse the repository at this point in the history
Closes: #1646
  • Loading branch information
eikek committed Oct 31, 2022
1 parent 54ee809 commit 7b85d51
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 2 deletions.
1 change: 1 addition & 0 deletions docker/dockerfiles/joex.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN JDKPKG="openjdk11-jre"; \
tesseract-ocr-data-heb \
tesseract-ocr-data-lit \
tesseract-ocr-data-pol \
tesseract-ocr-data-est \
unpaper \
wkhtmltopdf \
libreoffice \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ object DateFind {
case Language.Hebrew => dmy
case Language.Lithuanian => ymd
case Language.Polish => dmy
case Language.Estonian => dmy
}
p.read(parts) match {
case Result.Success(sds, _) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ object MonthName {
lithuanian
case Language.Polish =>
polish
case Language.Estonian =>
estonian
}

private val numbers = List(
Expand Down Expand Up @@ -375,4 +377,19 @@ object MonthName {
List("listopada", "lis"),
List("grudnia", "gru")
)

private val estonian = List(
List("jaanuar", "jaan"),
List("veebruar", "veebr"),
List("märts"),
List("aprill", "apr"),
List("mai"),
List("juuni"),
List("juuli"),
List("august", "aug"),
List("september", "sept"),
List("oktoober", "okt"),
List("november", "nov"),
List("detsember", "dets")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,32 @@ class DateFindTest extends FunSuite {
)
)
}

test("find estonian dates") {
assertEquals(
DateFind
.findDates(
"Some text in estonian 21 juuli 2022 and stuff",
Language.Estonian
)
.toVector,
Vector(
NerDateLabel(
LocalDate.of(2022, 7, 21),
NerLabel("21 juuli 2022", NerTag.Date, 22, 35)
)
)
)
assertEquals(
DateFind
.findDates("19.11.21", Language.Estonian)
.toVector,
Vector(
NerDateLabel(
LocalDate.of(2021, 11, 19),
NerLabel("19.11.21", NerTag.Date, 0, 8)
)
)
)
}
}
8 changes: 7 additions & 1 deletion modules/common/src/main/scala/docspell/common/Language.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ object Language {
val iso3 = "pol"
}

case object Estonian extends Language {
val iso2 = "et"
val iso3 = "est"
}

val all: List[Language] =
List(
German,
Expand All @@ -154,7 +159,8 @@ object Language {
Japanese,
Hebrew,
Lithuanian,
Polish
Polish,
Estonian
)

def fromString(str: String): Either[String, Language] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,6 @@ object FtsRepository extends DoobieMeta {
case Language.Hebrew => "simple"
case Language.Lithuanian => "simple"
case Language.Polish => "simple"
case Language.Estonian => "simple"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ object SolrSetup {
addContentField(Language.Polish)
),
SolrMigration.reIndexAll(26, "Re-Index after adding polish content field"),
SolrMigration.reIndexAll(27, "Re-Index after collective-id change")
SolrMigration.reIndexAll(27, "Re-Index after collective-id change"),
SolrMigration[F](
28,
"Add Estonian",
addContentField(Language.Estonian)
)
)

def addFolderField: F[Unit] =
Expand Down
8 changes: 8 additions & 0 deletions modules/webapp/src/main/elm/Data/Language.elm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Language
| Hungarian
| Lithuanian
| Polish
| Estonian


fromString : String -> Maybe Language
Expand Down Expand Up @@ -98,6 +99,9 @@ fromString str =
else if str == "pol" || str == "pl" || str == "polish" then
Just Polish

else if str == "est" || str == "et" || str == "estonian" then
Just Estonian

else
Nothing

Expand Down Expand Up @@ -165,6 +169,9 @@ toIso3 lang =
Polish ->
"pol"

Estonian ->
"est"


all : List Language
all =
Expand All @@ -188,4 +195,5 @@ all =
, Hungarian
, Lithuanian
, Polish
, Estonian
]
9 changes: 9 additions & 0 deletions modules/webapp/src/main/elm/Messages/Data/Language.elm
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ gb lang =
Polish ->
"Polish"

Estonian ->
"Estonian"


de : Language -> String
de lang =
Expand Down Expand Up @@ -141,6 +144,9 @@ de lang =
Polish ->
"Polnisch"

Estonian ->
"Estnisch"


fr : Language -> String
fr lang =
Expand Down Expand Up @@ -204,3 +210,6 @@ fr lang =

Polish ->
"Polonais"

Estonian ->
"Estonien"

0 comments on commit 7b85d51

Please sign in to comment.