Skip to content

Commit

Permalink
Merge pull request #1564 from dkpro/refactoring/1560-Upgrade-dependen…
Browse files Browse the repository at this point in the history
…cies

#1560 - Upgrade dependencies
  • Loading branch information
reckart authored Jun 10, 2023
2 parents 9d7d016 + d7309ba commit 69ab7a7
Show file tree
Hide file tree
Showing 437 changed files with 2,550 additions and 4,966 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import org.apache.uima.cas.impl.CASImpl;
import org.apache.uima.cas.impl.TypeImpl;
import org.apache.uima.cas.impl.TypeSystemImpl;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;


import org.apache.uima.jcas.tcas.Annotation;


Expand Down
10 changes: 0 additions & 10 deletions dkpro-core-api-datasets-asl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.dkpro.core</groupId>
<artifactId>dkpro-core-testing-asl</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
*/
package org.dkpro.core.api.datasets;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.dkpro.core.testing.DkproTestContext;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class DatasetFactoryTest
{
@Ignore("Used at times for offline testing / development")
@Disabled("Used at times for offline testing / development")
@Test
public void testOne()
throws Exception
Expand All @@ -48,7 +48,7 @@ public void testOne()
}
}

@Ignore("Used at times for offline testing / development")
@Disabled("Used at times for offline testing / development")
@Test
public void testLoadAll()
throws Exception
Expand All @@ -62,39 +62,33 @@ public void testLoadAll()
}
}

@Ignore("Used at times for offline testing / development")
@Disabled("Used at times for offline testing / development")
@Test
public void testShared()
public void testShared(@TempDir Path cache)
throws Exception
{
Path cache = testContext.getTestOutputFolder().toPath();

DatasetFactory df = new DatasetFactory(cache);
Dataset ds1 = df.load("perseus-el-2.1");
assertDatasetOk(ds1);
Dataset ds2 = df.load("perseus-la-2.1");
assertDatasetOk(ds2);
}

@Ignore("Used at times for offline testing / development")
@Disabled("Used at times for offline testing / development")
@Test
public void testLoadSimple()
public void testLoadSimple(@TempDir Path cache)
throws Exception
{
Path cache = testContext.getTestOutputFolder().toPath();

DatasetFactory df = new DatasetFactory(cache);
Dataset ds = df.load("germeval2014-de");
assertDatasetOk(ds);
}

@Ignore("Used at times for offline testing / development")
@Disabled("Used at times for offline testing / development")
@Test
public void testLoadWithExplode()
public void testLoadWithExplode(@TempDir Path cache)
throws Exception
{
Path cache = testContext.getTestOutputFolder().toPath();

DatasetFactory df = new DatasetFactory(cache);
Dataset ds = df.load("brown-en-teixml");
assertDatasetOk(ds);
Expand Down Expand Up @@ -134,11 +128,8 @@ private void assertNullOrExists(File... aFiles)
{
if (aFiles != null) {
for (File f : aFiles) {
assertTrue("File does not exist: [" + f + "]", f.exists());
assertThat(f).exists();
}
}
}

@Rule
public DkproTestContext testContext = new DkproTestContext();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,32 @@
*/
package org.dkpro.core.api.datasets;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.util.List;

import org.dkpro.core.api.datasets.Dataset;
import org.dkpro.core.api.datasets.DatasetLoader;
import org.dkpro.core.api.datasets.Split;
import org.dkpro.core.testing.DkproTestContext;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

@Ignore("Normally we do not run this")
@Disabled("Normally we do not run this")
public class DatasetLoaderTest
{
@Test
public void testUniversalDependencyTreebankV1_3()
public void testUniversalDependencyTreebankV1_3(@TempDir File tempDir)
throws Exception
{
List<Dataset> dss = new DatasetLoader(DkproTestContext.getCacheFolder())
List<Dataset> dss = new DatasetLoader(tempDir)
.loadUniversalDependencyTreebankV1_3();
for (Dataset ds : dss) {
assertDatasetOk(ds);
}
}
private void assertDatasetOk(Dataset ds)
{
assertNotNull("Name not set", ds.getName());
assertNotNull("Language not set", ds.getLanguage());
assertThat(ds.getName()).isNotNull();
assertThat(ds.getLanguage()).isNotNull();
Split split = ds.getDefaultSplit();
assertNullOrExists(split.getTestFiles());
assertNullOrExists(split.getTestFiles());
Expand All @@ -59,11 +54,8 @@ private void assertNullOrExists(File... aFiles)
{
if (aFiles != null) {
for (File f : aFiles) {
assertTrue("File does not exist: [" + f + "]", f.exists());
assertThat(f).exists();
}
}
}

@Rule
public DkproTestContext testContext = new DkproTestContext();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,29 @@
import java.io.IOException;
import java.nio.file.Path;

import org.dkpro.core.api.datasets.Dataset;
import org.dkpro.core.api.datasets.DatasetFactory;
import org.dkpro.core.testing.DkproTestContext;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;

@Ignore("Normally we do not run this")
@Disabled("Normally we do not run this")
public class FindEncoding
{
@Ignore("Used at times for offline testing / development")
private @TempDir Path cache;

@Disabled("Used at times for offline testing / development")
@Test
public void getEncoding() throws IOException
{
String dsName = "ndt-nn-1.01";
findEncoding(dsName);
}

@Ignore("Used at times for offline testing / development")
@Disabled("Used at times for offline testing / development")
public void findEncoding(String eName) throws IOException
{
Path cache = testContext.getCacheFolder().toPath();
DatasetFactory df = new DatasetFactory(cache);
Dataset ds = df.load(eName);
for (File fnew : ds.getDataFiles()) {
Expand All @@ -64,7 +62,4 @@ public void findEncoding(String eName) throws IOException
}
}
}

@Rule
public DkproTestContext testContext = new DkproTestContext();
}
12 changes: 0 additions & 12 deletions dkpro-core-api-embeddings-asl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
<relativePath>../dkpro-core-asl</relativePath>
</parent>
<artifactId>dkpro-core-api-embeddings-asl</artifactId>
<packaging>jar</packaging>
<name>DKPro Core ASL - Embeddings API (ASL)</name>
<url>https://dkpro.github.io/dkpro-core/</url>
<dependencies>
<dependency>
<groupId>org.dkpro.core</groupId>
Expand All @@ -40,15 +38,5 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.dkpro.core</groupId>
<artifactId>dkpro-core-testing-asl</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,21 @@
*/
package org.dkpro.core.api.embeddings;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.Arrays;

import org.dkpro.core.testing.DkproTestContext;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class VectorizerUtilsTest
{
@Rule
public DkproTestContext testContext = new DkproTestContext();

@Test
public void testRandomVectorStable()
throws IOException
public void testRandomVectorStable() throws IOException
{
float[] unk1 = VectorizerUtils.randomVector(3);
float[] unk2 = VectorizerUtils.randomVector(3);
assertTrue("Random vector for unknown words should always be the same.",
Arrays.equals(unk1, unk2));
assertTrue(Arrays.equals(unk1, unk2),
"Random vector for unknown words should always be the same.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*/
package org.dkpro.core.api.embeddings.binary;

import static org.assertj.core.api.Assertions.assertThat;
import static org.dkpro.core.api.embeddings.binary.BinaryWordVectorUtils.convertWordVectorsToBinary;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
Expand All @@ -29,19 +30,18 @@
import java.util.Map;

import org.dkpro.core.api.embeddings.VectorizerUtils;
import org.dkpro.core.testing.DkproTestContext;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class BinaryWordVectorUtilsTest
{
private @TempDir File tempDir;

// TODO: test for very large data (>2GB should be chunked)
@Rule
public DkproTestContext testContext = new DkproTestContext();
private Map<String, float[]> vectors;

@Before
@BeforeEach
public void setUp()
{
vectors = new HashMap<>();
Expand All @@ -57,17 +57,17 @@ public void testConvertWordVectorsToBinary()

BinaryVectorizer vec = BinaryVectorizer.load(binaryTarget);

assertTrue(vec.contains("t1"));
assertTrue(vec.contains("t2"));
assertEquals(3, vec.dimensions());
assertEquals(2, vec.size());
assertTrue(vec.isCaseless());
assertThat(vec.contains("t1")).isTrue();
assertThat(vec.contains("t2")).isTrue();
assertThat(vec.dimensions()).isEqualTo(3);
assertThat(vec.size()).isEqualTo(2);
assertThat(vec.isCaseless()).isTrue();

for (String word : vectors.keySet()) {
float[] orig = vectors.get(word);
float[] conv = vec.vectorize(word);

assertTrue("Vectors differ for " + word, Arrays.equals(orig, conv));
assertThat(conv).containsExactly(orig);
}
}

Expand All @@ -92,7 +92,7 @@ public void testConvertWordVectorsToBinaryCaseSensitive()
float[] orig = vectors.get(word);
float[] conv = vec.vectorize(word);

assertTrue("Vectors differ for " + word, Arrays.equals(orig, conv));
assertTrue(Arrays.equals(orig, conv), "Vectors differ for " + word);
}
}

Expand All @@ -109,8 +109,8 @@ public void testRandomVector()
float[] unk2 = vec.vectorize("unk2");
assertTrue(Arrays.equals(randVector, unk1));
assertTrue(Arrays.equals(randVector, unk2));
assertTrue("Vectors or unknown words should always be the same.",
Arrays.equals(unk1, unk2));
assertTrue(
Arrays.equals(unk1, unk2), "Vectors or unknown words should always be the same.");
}

/**
Expand All @@ -122,7 +122,7 @@ public void testRandomVector()
private File writeBinaryFile(Map<String, float[]> vectors)
throws IOException
{
File binaryTarget = new File(testContext.getTestOutputFolder(), "binaryTarget");
File binaryTarget = new File(tempDir, "binaryTarget");
convertWordVectorsToBinary(vectors, binaryTarget);
return binaryTarget;
}
Expand Down
Loading

0 comments on commit 69ab7a7

Please sign in to comment.