Skip to content

Commit

Permalink
Merge branch 'master' into feature/issue1190-maui
Browse files Browse the repository at this point in the history
  • Loading branch information
reckart committed May 4, 2019
2 parents 741a18e + 7097287 commit 6507c15
Show file tree
Hide file tree
Showing 19 changed files with 140 additions and 144 deletions.
2 changes: 1 addition & 1 deletion dkpro-core-api-datasets-asl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>com.github.junrar</groupId>
<artifactId>junrar</artifactId>
<version>0.7</version>
<version>4.0.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
Expand Down
4 changes: 2 additions & 2 deletions dkpro-core-api-resources-asl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
package org.dkpro.core.api.resources;

import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.is;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.io.File;
Expand Down Expand Up @@ -103,13 +102,13 @@ public void testGetUrlAsExecutable()
URL url = new URL("jar:file:src/test/resources/testfiles.zip!/testfiles/"
+ "FileSetCollectionReaderBase.class");
File file = ResourceUtils.getUrlAsExecutable(url, false);
assertThat(file.getName().endsWith("temp"), is(true));

assertThat(file.getName()).endsWith("temp");

URL url2 = new URL("jar:file:src/test/resources/testfiles.zip!/testfiles/"
+ "ResourceCollectionReaderBase.class");
file = ResourceUtils.getUrlAsExecutable(url2, true);
assertThat(file.getName().endsWith("temp"), is(true));


assertThat(file.getName()).endsWith("temp");
}

}
4 changes: 2 additions & 2 deletions dkpro-core-api-segmentation-asl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
*/
package org.dkpro.core.api.segmentation;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Compound.CompoundSplitLevel.ALL;
import static de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Compound.CompoundSplitLevel.HIGHEST;
import static de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Compound.CompoundSplitLevel.LOWEST;
import static de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Compound.CompoundSplitLevel.NONE;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -33,13 +36,11 @@
import org.junit.Test;

import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Compound;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Compound.CompoundSplitLevel;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.CompoundPart;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Split;

public class CompoundTest
{

private Compound compound;

@Before
Expand All @@ -66,62 +67,39 @@ public void setUpCompound() throws UIMAException
compound.setSplits(FSCollectionFactory.createFSArray(jcas, splits));
compound.addToIndexes();
jcasBuilder.close();

}

@Test
public void testAll() throws UIMAException
{

final String[] splitsList = new String[] { "getränk", "automat", "auto", "mat" };
assertThat(coveredTextArrayFromAnnotations(
compound.getSplitsWithoutMorpheme(CompoundSplitLevel.ALL)), is(splitsList));

assertThat(compound.getSplitsWithoutMorpheme(ALL))
.extracting(Annotation::getCoveredText)
.containsExactly("getränk", "automat", "auto", "mat");
}

@Test
public void testLowest() throws UIMAException
{

final String[] splitsList = new String[] { "getränk", "auto", "mat" };
assertThat(
coveredTextArrayFromAnnotations(
compound.getSplitsWithoutMorpheme(CompoundSplitLevel.LOWEST)),
is(splitsList));
assertThat(compound.getSplitsWithoutMorpheme(LOWEST))
.extracting(Annotation::getCoveredText)
.containsExactly("getränk", "auto", "mat");

}

@Test
public void testHighest() throws UIMAException
{

final String[] splitsList = new String[] { "getränk", "automat" };
assertThat(
coveredTextArrayFromAnnotations(
compound.getSplitsWithoutMorpheme(CompoundSplitLevel.HIGHEST)),
is(splitsList));
assertThat(compound.getSplitsWithoutMorpheme(HIGHEST))
.extracting(Annotation::getCoveredText)
.containsExactly("getränk", "automat");

}

@Test
public void testNone() throws UIMAException
{

final String[] splitsList = new String[] {};
assertThat(
coveredTextArrayFromAnnotations(
compound.getSplitsWithoutMorpheme(CompoundSplitLevel.NONE)),
is(splitsList));

}

public <T extends Annotation> String[] coveredTextArrayFromAnnotations(final T[] annotations)
{
final List<String> list = new ArrayList<String>();
for (T annotation : annotations) {
list.add(annotation.getCoveredText());
}
return list.toArray(new String[list.size()]);
assertThat(compound.getSplitsWithoutMorpheme(NONE))
.extracting(Annotation::getCoveredText)
.isEmpty();
}

}
4 changes: 2 additions & 2 deletions dkpro-core-decompounding-asl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@

package org.dkpro.core.decompounding.dictionary;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;

import org.dkpro.core.api.resources.ResourceUtils;
import org.dkpro.core.decompounding.dictionary.SimpleDictionary;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -47,18 +46,17 @@ public void setUp() throws IOException
@Test
public void testContains()
{
Assert.assertEquals(72508, dict.getAll().size());
assertEquals(72508, dict.getAll().size());

Assert.assertTrue(dict.contains("worauf"));
Assert.assertTrue(dict.contains("woraufhin"));
Assert.assertTrue(dict.contains("woraus"));
assertTrue(dict.contains("worauf"));
assertTrue(dict.contains("woraufhin"));
assertTrue(dict.contains("woraus"));
}

@Test
public void testDictionary()
{
assertThat(dict.getAll().size(), not(0));
assertThat(dict.contains("zu"), is(true));
assertThat(dict.getAll()).isNotEmpty();
assertThat(dict.contains("zu")).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
**/
package org.dkpro.core.decompounding.splitter;

import static org.hamcrest.CoreMatchers.is;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import java.io.File;
import java.io.IOException;
Expand All @@ -41,6 +40,7 @@ public void testSplitter() throws IOException
splitter.setDictionary(new SimpleDictionary("Garage", "einfahrt"));

List<DecompoundedWord> result = splitter.split("Garageneinfahrt").getAllSplits();

assertEquals(2, result.size());
assertEquals("Garageneinfahrt", result.get(0).toString());
assertEquals("garage(n)+einfahrt", result.get(1).toString());
Expand All @@ -55,7 +55,9 @@ public void testSplitter2() throws IOException
Dictionary dict = new SimpleDictionary(dictFile, "UTF-8");
BananaSplitterAlgorithm splitter = new BananaSplitterAlgorithm();
splitter.setDictionary(dict);

List<DecompoundedWord> result = splitter.split("geräteelektronik").getAllSplits();
assertThat(result.size(), is(1));

assertThat(result).hasSize(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@

package org.dkpro.core.decompounding.splitter;

import static org.hamcrest.CoreMatchers.is;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import java.io.File;
import java.io.IOException;
Expand All @@ -29,8 +28,6 @@
import org.dkpro.core.api.resources.ResourceUtils;
import org.dkpro.core.decompounding.dictionary.LinkingMorphemes;
import org.dkpro.core.decompounding.dictionary.SimpleDictionary;
import org.dkpro.core.decompounding.splitter.DataDrivenSplitterAlgorithm;
import org.dkpro.core.decompounding.splitter.DecompoundedWord;
import org.junit.Test;

public class DataDrivenAlgorithmTest
Expand Down Expand Up @@ -64,6 +61,7 @@ public void testSplit2() throws IOException
LinkingMorphemes morphemes = new LinkingMorphemes(morphemesFile);
DataDrivenSplitterAlgorithm splitter = new DataDrivenSplitterAlgorithm(dict, morphemes);
List<DecompoundedWord> result = splitter.split("geräteelektronik").getAllSplits();
assertThat(result.size(), is(1));

assertThat(result).hasSize(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

package org.dkpro.core.decompounding.splitter;

import static org.hamcrest.CoreMatchers.is;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
Expand Down Expand Up @@ -145,16 +144,18 @@ public void testIsCompound()
{
DecompoundedWord s1 = DecompoundedWord.createFromString("Aktion(s)+plan");
DecompoundedWord s2 = DecompoundedWord.createFromString("Aktionsplan");
assertThat(s1.isCompound(), is(true));
assertThat(s2.isCompound(), is(false));

assertThat(s1.isCompound()).isTrue();
assertThat(s2.isCompound()).isFalse();
}

@Test
public void testHasLastFragmentMorpheme()
{
DecompoundedWord s1 = DecompoundedWord.createFromString("Aktion(s)+plan");
DecompoundedWord s2 = DecompoundedWord.createFromString("unter+flur+konvektor(en)");
assertThat(s1.hasLastFragmentMorpheme(), is(false));
assertThat(s2.hasLastFragmentMorpheme(), is(true));

assertThat(s1.hasLastFragmentMorpheme()).isFalse();
assertThat(s2.hasLastFragmentMorpheme()).isTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

package org.dkpro.core.decompounding.splitter;

import static org.assertj.core.api.Assertions.assertThat;

import org.dkpro.core.decompounding.splitter.Fragment;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -72,6 +73,7 @@ public void testEquals()
public void testCreateFromString()
{
Fragment fragm = Fragment.createFromString("(");
Assert.assertThat(fragm.getWord(), CoreMatchers.is("("));

assertThat(fragm.getWord()).isEqualTo("(");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
**/
package org.dkpro.core.decompounding.splitter;

import static org.hamcrest.CoreMatchers.is;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import java.io.File;
import java.io.IOException;
Expand All @@ -40,6 +39,7 @@ public void testSplitter()
{
JWordSplitterAlgorithm splitter = new JWordSplitterAlgorithm();
List<DecompoundedWord> result = splitter.split("Aktionsplan").getAllSplits();

assertEquals(2, result.size());
assertEquals("Aktionsplan", result.get(0).toString());
assertEquals("Aktion(s)+plan", result.get(1).toString());
Expand All @@ -51,12 +51,12 @@ public void testSplliter2() throws IOException {
final File dictFile = ResourceUtils.getUrlAsFile(getClass().getResource(
"/de/tudarmstadt/ukp/dkpro/core/decompounding/lib/spelling-de-igerman98.dic"),
false);
;

Dictionary dict = new SimpleDictionary(dictFile, "UTF-8");
splitter.setDictionary(dict);
List<DecompoundedWord> result = splitter.split("geräteelektronik").getAllSplits();
assertThat(result.size(),is(1));

assertThat(result).hasSize(1);
}

@Test
Expand All @@ -65,11 +65,11 @@ public void testSplliter3() throws IOException {
final File dictFile = ResourceUtils.getUrlAsFile(getClass().getResource(
"/de/tudarmstadt/ukp/dkpro/core/decompounding/lib/spelling-de-igerman98.dic"),
false);
;

Dictionary dict = new SimpleDictionary(dictFile, "UTF-8");
splitter.setDictionary(dict);
List<DecompoundedWord> result = splitter.split("Schwerwiegend").getAllSplits();
assertThat(result.size(),is(1));

assertThat(result).hasSize(1);
}
}
Loading

0 comments on commit 6507c15

Please sign in to comment.