Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/before-push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- uses: actions/checkout@v6
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'adopt'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
21 changes: 16 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
FROM gradle:8.0.2-jdk11-alpine AS build
FROM gradle:9.5.1-jdk25-alpine AS build
RUN mkdir annotace
WORKDIR /annotace
COPY . .
RUN gradle bootJar -x test

FROM eclipse-temurin:11-jdk-alpine AS runtime
COPY --from=build /annotace/core/build/libs/*.jar /
RUN mv annotace*.jar annotace.jar
FROM eclipse-temurin:25-jdk-alpine AS runtime
# Run as a non-root user. Spark NLP downloads pretrained models on startup into
# its cache folder (defaults to ~/cache_pretrained), and Spark writes runtime
# artifacts (metastore_db, spark-warehouse) into the working directory, so the
# user needs a writable home and working directory.
RUN addgroup -S annotace \
&& adduser -S -G annotace -h /home/annotace annotace \
&& mkdir -p /app \
&& chown -R annotace:annotace /app /home/annotace
WORKDIR /app
COPY --from=build --chown=annotace:annotace /annotace/core/build/libs/annotace-*.jar /app/annotace.jar

EXPOSE 8080
ENTRYPOINT ["java","-jar","/annotace.jar"]
ENV HOME=/home/annotace
ENV JDK_JAVA_OPTIONS="--add-opens java.base/sun.nio.ch=ALL-UNNAMED java.base/java.nio=ALL-UNNAMED java.base/java.util=ALL-UNNAMED java.base/java.lang=ALL-UNNAMED java.base/java.lang.invoke=ALL-UNNAMED"
USER annotace
ENTRYPOINT ["java","-XX:+UseCompactObjectHeaders","-jar","/app/annotace.jar"]
19 changes: 12 additions & 7 deletions Dockerfile-morphodita
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@ COPY $MORPHODITA_ZIP /morphodita
WORKDIR /morphodita
RUN unzip *.zip

FROM gradle:8.0.2-jdk11-alpine AS build
FROM gradle:9.5.1-jdk25-alpine AS build
ARG MORPHODITA_ZIP_SO
RUN mkdir annotace
WORKDIR /annotace
COPY . .
RUN gradle clean bootJar -x test

FROM eclipse-temurin:11-jdk-alpine AS runtime
FROM eclipse-temurin:25-jdk-alpine AS runtime
ARG MORPHODITA_ZIP_SO
# Work around an issue with missing library on Alpine Linux - https://www.svlada.com/fun-times-with-gcc-musl-alpine-linux/
RUN apk add --update --no-cache libc6-compat
COPY --from=build /annotace/core/build/libs/annotace-*.jar /
RUN mv *.jar annotace.jar
COPY --from=unzip /morphodita/$MORPHODITA_ZIP_SO /lib
RUN apk add --update --no-cache libc6-compat \
&& addgroup -S annotace \
&& adduser -S -G annotace annotace
WORKDIR /app
COPY --from=build --chown=annotace:annotace /annotace/core/build/libs/annotace-*.jar /app/annotace.jar
COPY --from=unzip /morphodita/$MORPHODITA_ZIP_SO /lib/
# Ensure the MorphoDita native library is readable/executable by the non-root user
RUN chmod -R a+rX "/lib/$(basename "$MORPHODITA_ZIP_SO")"

EXPOSE 8080
ENTRYPOINT ["java","-jar","/annotace.jar"]
USER annotace
ENTRYPOINT ["java","-XX:+UseCompactObjectHeaders","-jar","/app/annotace.jar"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Annotace is a text analysis service used e.g. by [TermIt](https://github.com/kbs

## How to run it?

- Install Java 11
- Install Java 21
- Run `./gradlew bootRun` (on Linux/WSL) or `gradlew.bat bootRun` on Windows

## Lemmatizers
Expand Down Expand Up @@ -39,7 +39,7 @@ A complete command line example would be:

1. Download the MorphoDiTa [ZIP archive](https://github.com/ufal/morphodita/releases/download/v1.9.2/morphodita-1.9.2-bin.zip).
2. Set `MORPHODITA_ZIP` in `docker-compose-morphodita.yml` to path to the downloaded MorphoDiTa ZIP file.
3. Download and extract taggers (language models). Put them into a single directory.
3. Download and extract taggers (language models). Put them into a 11single directory.
4. Set `MORPHODITA_TAGGERS` in `docker-compose-morphodita.yml` to path to the taggers' directory.
5. Run `docker compose -f docker-compose-morphodita.yml up -d --build` to build and start Annotace wih MorphoDiTa.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
46 changes: 21 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
plugins {
id "org.springframework.boot" version "2.7.10" apply false
id "io.spring.dependency-management" version "1.0.11.RELEASE" apply false
id "com.github.hierynomus.license" version "0.16.1"
id "org.springframework.boot" version "4.1.0" apply false
id "io.spring.dependency-management" version "1.1.7" apply false
id "com.diffplug.spotless" version "7.0.4" apply false
}

group "cz.cvut.kbss"
description "Text analysis for Czech language and annotation recommendation service"
version "0.0.1"
group = "cz.cvut.kbss"
description = "Text analysis for Czech language and annotation recommendation service"
version = "0.1.0"

def revision = "git rev-list --count HEAD".execute().text.trim()
def hash = "git rev-parse --short HEAD".execute().text.trim()
version = "0.0.1.r${revision}.${hash}"

ext {
junitVersion = "5.9.2"
}
version = "0.1.0.r${revision}.${hash}"

subprojects {
apply plugin: "java"
apply plugin: "java-library"
apply plugin: "com.github.hierynomus.license"
apply plugin: "com.diffplug.spotless"

compileJava {
sourceCompatibility = "11"
targetCompatibility = "11"
sourceCompatibility = "21"
targetCompatibility = "21"
}

test {
useJUnitPlatform()
}

license {
header = rootProject.file("header.txt")
excludes(["**/*.txt", "**/*.yml", "**/*.html", "**/*.xml", "**/*.ttl"])
mapping {
java = "SLASHSTAR_STYLE"
spotless {
java {
target "src/**/*.java"
licenseHeaderFile rootProject.file("header.txt"), "package "
}
}

group parent.group
version parent.version
group = parent.group
version = parent.version

repositories {
mavenCentral()
Expand All @@ -50,13 +45,14 @@ subprojects {
}

dependencies {
implementation "org.slf4j:slf4j-api:1.7.36"
implementation "ch.qos.logback:logback-classic:1.2.11"
compileOnly "org.projectlombok:lombok:1.18.20"
implementation "org.slf4j:slf4j-api:2.0.17"
implementation "ch.qos.logback:logback-classic:1.5.34"
compileOnly "org.projectlombok:lombok:1.18.32"

annotationProcessor "org.projectlombok:lombok:1.18.20"
annotationProcessor "org.projectlombok:lombok:1.18.32"

testImplementation(libs.junit.api)
testRuntimeOnly(libs.junit.engine)
testRuntimeOnly(libs.junit.platform.launcher)
}
}
21 changes: 13 additions & 8 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
apply plugin: "org.springframework.boot"
apply plugin: "io.spring.dependency-management"

description "Text analysis for Czech language and annotation recommendation service"
description = "Text analysis for Czech language and annotation recommendation service"

def applicationVersion = project.version

processResources {
filesMatching("application.yml") {
expand(["version": project.version])
expand(["version": applicationVersion])
}
}

Expand All @@ -16,23 +18,26 @@ dependencies {
implementation project(":lemmatizer-morphodita")

implementation(libs.spring.boot.web)
implementation("org.jsoup:jsoup:1.15.4")
implementation("org.jsoup:jsoup:1.18.1")

implementation(libs.jackson.annotations)
implementation("org.apache.jena:apache-jena-libs:3.17.0")
implementation("org.apache.jena:jena-arq:6.0.0")

testImplementation("org.apache.commons:commons-lang3:3.12.0")
testImplementation("org.mockito:mockito-junit-jupiter:4.0.0")
testImplementation("org.apache.commons:commons-lang3:3.20.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")

}

test {
jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.nio=ALL-UNNAMED", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED"
}

allprojects {
configurations.configureEach {
resolutionStrategy {
dependencySubstitution {
substitute module("org.codehaus.janino:janino") using module("org.codehaus.janino:janino:3.0.16")
substitute module("org.codehaus.janino:commons-compiler") using module("org.codehaus.janino:commons-compiler:3.0.16")
substitute module("org.codehaus.janino:janino") using module("org.codehaus.janino:janino:3.1.9")
substitute module("org.codehaus.janino:commons-compiler") using module("org.codehaus.janino:commons-compiler:3.1.9")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/cz/cvut/kbss/textanalysis/App.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -25,10 +25,10 @@
import cz.cvut.kbss.textanalysis.lemmatizer.LemmatizerApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient;

@Configuration
@Slf4j
Expand All @@ -39,17 +39,20 @@ public class LemmatizerConfig {

@Bean
public LemmatizerApi lemmatizer(ApplicationContext context) {
switch (lemmatizer) {
case "morphodita-jni":
return switch (lemmatizer) {
case "morphodita-jni" -> {
log.info("Instantiating MorphoDiTa JNI lemmatizer.");
return new MorphoDitaServiceJNI(context.getBean(MorphoditaConf.class));
case "morphodita-online":
yield new MorphoDitaServiceJNI(context.getBean(MorphoditaConf.class));
}
case "morphodita-online" -> {
log.info("Instantiating MorhoDiTa online lemmatizer.");
return new MorphoDitaServiceOnline(context.getBean(RestTemplateBuilder.class), context.getBean(
yield new MorphoDitaServiceOnline(RestClient.builder(), context.getBean(
MorphoditaConf.class));
default:
}
default -> {
log.info("Instantiating Apache Spark lemmatizer.");
return new SparkLemmatizer(context.getBean(SparkConf.class));
}
yield new SparkLemmatizer(context.getBean(SparkConf.class));
}
};
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Annotace
* Copyright (C) 2024 Czech Technical University in Prague
* Copyright (C) 2026 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Loading