Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kotlin language #1096

Merged
merged 8 commits into from
May 5, 2024
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
12 changes: 7 additions & 5 deletions .github/workflows/ci-build-unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 1.17
java-version: '17.0.10+7'
distribution: 'temurin'
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew clean assemble --info --stacktrace --no-daemon

Expand All @@ -38,10 +40,10 @@ jobs:
steps:
- name: Create more disk space
run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build and push
id: docker_build
uses: mr-smithers-excellent/docker-build-push@v5
uses: mr-smithers-excellent/docker-build-push@v6
with:
username: ${{ secrets.DOCKERHUB_USERNAME_LFOPPIANO }}
password: ${{ secrets.DOCKERHUB_TOKEN_LFOPPIANO }}
Expand Down
29 changes: 25 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ buildscript {
classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0'
classpath "gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0"
classpath 'com.adarshr:gradle-test-logger-plugin:2.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21"
}
}

repositories {
mavenLocal()
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}

apply plugin: 'jacoco'
Expand All @@ -29,6 +33,7 @@ allprojects {
apply plugin: 'base'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'com.adarshr.test-logger'
apply plugin: 'org.jetbrains.kotlin.jvm'

group = "org.grobid"

Expand All @@ -55,8 +60,18 @@ subprojects {
}
}

sourceCompatibility = 1.11
targetCompatibility = 1.11
// sourceCompatibility = 1.11
// targetCompatibility = 1.11

kotlin {
jvmToolchain(17)
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

repositories {
mavenCentral()
Expand Down Expand Up @@ -86,14 +101,20 @@ subprojects {
// packaging local libs inside grobid-core.jar
implementation fileTree(dir: new File(rootProject.rootDir, 'grobid-core/localLibs'), include: localLibs)

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.9.3'
testImplementation(platform('org.junit:junit-bom:5.9.3'))
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine"
testImplementation(platform('org.junit:junit-bom:5.10.2'))
testRuntimeOnly("org.junit.platform:junit-platform-launcher") {
because("Only needed to run tests in a version of IntelliJ IDEA that bundles older versions")
}
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation 'org.easymock:easymock:5.1.0'
testImplementation "org.powermock:powermock-api-easymock:2.0.7"
testImplementation "org.powermock:powermock-module-junit4:2.0.7"
testImplementation "xmlunit:xmlunit:1.6"
testImplementation "org.hamcrest:hamcrest-all:1.3"
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation "io.mockk:mockk:1.13.9"

implementation "com.cybozu.labs:langdetect:1.1-20120112"
implementation "com.rockymadden.stringmetric:stringmetric-core_2.11:0.27.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public static boolean toSkipToken(String tok) {
return false;
}

private static boolean toSkipTokenNoHyphen(String tok) {
static boolean toSkipTokenNoHyphen(String tok) {
if (tok.equals(" ") || tok.equals("\n") || tok.equals("\t"))
return true;
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.grobid.core.utilities

import org.junit.Test
import kotlin.test.assertFalse
import kotlin.test.assertTrue

class SentenceUtilitiesKTest {

@Test
fun testToSkipToken_shouldReturnTrue() {
val tokens = arrayOf("-", " ", "\n", "\t")

tokens.forEach { token ->
assertTrue(SentenceUtilities.toSkipToken(token))
}

}

@Test
fun testToSkipTokenNoHypen_shouldReturnTrue() {
val tokens = arrayOf(" ", "\n", "\t")

tokens.forEach { token ->
assertTrue(SentenceUtilities.toSkipTokenNoHyphen(token))
}

assertFalse { SentenceUtilities.toSkipTokenNoHyphen("-") }

}


}
Loading