diff --git a/src/main/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/DEWordFormNounTableHandler.java b/src/main/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/DEWordFormNounTableHandler.java index 1605e7b..1c35107 100644 --- a/src/main/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/DEWordFormNounTableHandler.java +++ b/src/main/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/DEWordFormNounTableHandler.java @@ -18,7 +18,9 @@ package de.tudarmstadt.ukp.jwktl.parser.de.components.nountable; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryWordForm; import de.tudarmstadt.ukp.jwktl.parser.de.components.DEGenderText; @@ -26,9 +28,11 @@ import de.tudarmstadt.ukp.jwktl.parser.util.ParsingContext; public class DEWordFormNounTableHandler implements ITemplateParameterHandler { + + public static final int MAX_INFLECTION_GROUP_COUNT = 4; public void reset() { - this.genera = new DEGenderText[4]; + this.genera = new HashMap<>(DEWordFormNounTableHandler.MAX_INFLECTION_GROUP_COUNT); } private List handlers = Arrays.asList( @@ -51,32 +55,24 @@ public void reset() { // Accusative new AccusativeHandler()); - protected DEGenderText[] genera = new DEGenderText[4]; + protected Map genera = new HashMap<>(DEWordFormNounTableHandler.MAX_INFLECTION_GROUP_COUNT); /** * Returns genus by index. - * @param index index of the genus, must be between 1 and 4. + * @param index index of the genus. * @return Genus by index or null if genus by this index was not set yet. - * @throws IllegalArgumentException If index is not between 1 and 4. */ DEGenderText getGenusByIndex(int index) { - if (index < 1 || index > 4) { - throw new IllegalArgumentException("Genus index must be 1, 2, 3 or 4."); - } - return genera[index - 1]; + return genera.get(index - 1); } /** * Sets genus by index * @param genderText genus. - * @param index index of the genus, must be between 1 and 4. - * @throws IllegalArgumentException If index is not between 1 and 4. + * @param index index of the genus. */ - void setGenusByIndex(DEGenderText genderText, Integer index) { - if (index < 1 || index > 4) { - throw new IllegalArgumentException("Genus index must be 1, 2, 3 or 4."); - } - this.genera[index - 1] = genderText; + void setGenusByIndex(DEGenderText genderText, int index) { + this.genera.put(index - 1, genderText); } @Override diff --git a/src/main/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/PatternBasedIndexedParameterHandler.java b/src/main/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/PatternBasedIndexedParameterHandler.java index 5ed787b..159ff8c 100644 --- a/src/main/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/PatternBasedIndexedParameterHandler.java +++ b/src/main/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/PatternBasedIndexedParameterHandler.java @@ -17,9 +17,12 @@ ******************************************************************************/ package de.tudarmstadt.ukp.jwktl.parser.de.components.nountable; +import java.util.List; import java.util.Objects; import java.util.regex.Matcher; +import de.tudarmstadt.ukp.jwktl.api.IWiktionaryWordForm; +import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryEntry; import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryWordForm; import de.tudarmstadt.ukp.jwktl.parser.util.ParsingContext; import de.tudarmstadt.ukp.jwktl.parser.util.PatternUtils; @@ -36,14 +39,28 @@ public PatternBasedIndexedParameterHandler(DEWordFormNounTableHandler nounTableH public void handle(String label, String value, WiktionaryWordForm wordForm, ParsingContext context) { final Matcher matcher = pattern.matcher(label); + + WiktionaryEntry wiktionaryEntry = context.findEntry(); + + List wordForms = wiktionaryEntry.getWordForms(); + final int indexOffset; + if (wordForms == null) { + indexOffset = 0; + } else { + final int maxInflectionGroup = wordForms.stream().mapToInt(IWiktionaryWordForm::getInflectionGroup).max() + .orElse(0); + indexOffset = (((maxInflectionGroup - 1) / DEWordFormNounTableHandler.MAX_INFLECTION_GROUP_COUNT) + 1) + * DEWordFormNounTableHandler.MAX_INFLECTION_GROUP_COUNT; + } + if (matcher.find()) { final Integer index = PatternUtils.extractIndex(matcher); - final int i = index == null ? 1 : index.intValue(); - handleIfFound(wordForm, label, i, value, matcher, context); + final int i = index == null ? 1 : index.intValue(); + handleIfFound(wordForm, label, i + indexOffset, value, matcher, context); } } - public abstract void handleIfFound(WiktionaryWordForm wordForm, String label, int index, String value, Matcher matcher, - ParsingContext context); + public abstract void handleIfFound(WiktionaryWordForm wordForm, String label, int index, String value, + Matcher matcher, ParsingContext context); } diff --git a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/DEWordFormHandlerTest.java b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/DEWordFormHandlerTest.java index 6547ea0..5ce8171 100644 --- a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/DEWordFormHandlerTest.java +++ b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/DEWordFormHandlerTest.java @@ -516,6 +516,31 @@ public void testGams() throws Exception { assertWordFormNoun("Gamsen", ACCUSATIVE, PLURAL, null, 1, actualIter.next()); assertFalse(actualIter.hasNext()); } + + /***/ + public void testApfelschorle() throws Exception { + IWiktionaryPage page = parse("Apfelschorle.txt"); + IWiktionaryEntry entry = page.getEntry(0); + Iterator actualIter = entry.getWordForms().iterator(); + assertWordFormNoun("Apfelschorle", NOMINATIVE, SINGULAR, NEUTER, 1, actualIter.next()); + assertWordFormNoun("Apfelschorles", NOMINATIVE, PLURAL, null, 1, actualIter.next()); + assertWordFormNoun("Apfelschorles", GENITIVE, SINGULAR, NEUTER, 1, actualIter.next()); + assertWordFormNoun("Apfelschorles", GENITIVE, PLURAL, null, 1, actualIter.next()); + assertWordFormNoun("Apfelschorle", DATIVE, SINGULAR, NEUTER, 1, actualIter.next()); + assertWordFormNoun("Apfelschorles", DATIVE, PLURAL, null, 1, actualIter.next()); + assertWordFormNoun("Apfelschorle", ACCUSATIVE, SINGULAR, NEUTER, 1, actualIter.next()); + assertWordFormNoun("Apfelschorles", ACCUSATIVE, PLURAL, null, 1, actualIter.next()); + + assertWordFormNoun("Apfelschorle", NOMINATIVE, SINGULAR, FEMININE, 5, actualIter.next()); + assertWordFormNoun("Apfelschorlen", NOMINATIVE, PLURAL, null, 5, actualIter.next()); + assertWordFormNoun("Apfelschorle", GENITIVE, SINGULAR, FEMININE, 5, actualIter.next()); + assertWordFormNoun("Apfelschorlen", GENITIVE, PLURAL, null, 5, actualIter.next()); + assertWordFormNoun("Apfelschorle", DATIVE, SINGULAR, FEMININE, 5, actualIter.next()); + assertWordFormNoun("Apfelschorlen", DATIVE, PLURAL, null, 5, actualIter.next()); + assertWordFormNoun("Apfelschorle", ACCUSATIVE, SINGULAR, FEMININE, 5, actualIter.next()); + assertWordFormNoun("Apfelschorlen", ACCUSATIVE, PLURAL, null, 5, actualIter.next()); + assertFalse(actualIter.hasNext()); + } protected void assertWordFormNoun(final String expectedForm, final GrammaticalCase expectedCase, final GrammaticalNumber expectedNumber, GrammaticalGender expectedGender, diff --git a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/DEWordFormNounTableHandlerTest.java b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/DEWordFormNounTableHandlerTest.java index dd541dd..19ed829 100644 --- a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/DEWordFormNounTableHandlerTest.java +++ b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/DEWordFormNounTableHandlerTest.java @@ -37,35 +37,4 @@ public void testGetsSetGenus() { public void testGetsNotSetGenus() { assertNull(nounTableHandler.getGenusByIndex(3)); } - - public void testThrowsExceptionSettingGenusWithInvalidIndex() { - try { - nounTableHandler.setGenusByIndex(DEGenderText.F, 0); - fail(); - } catch (IllegalArgumentException expected) { - assertTrue(true); - } - try { - nounTableHandler.setGenusByIndex(DEGenderText.F, 5); - fail(); - } catch (IllegalArgumentException expected) { - assertTrue(true); - } - } - - public void testThrowsExceptionGettingGenusWithInvalidIndex() { - try { - nounTableHandler.getGenusByIndex(0); - fail(); - } catch (IllegalArgumentException expected) { - assertTrue(true); - } - try { - nounTableHandler.getGenusByIndex(5); - fail(); - } catch (IllegalArgumentException expected) { - assertTrue(true); - } - } - -} +} \ No newline at end of file diff --git a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/EinzahlHandlerTest.java b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/EinzahlHandlerTest.java index 9fe120b..c53e1b0 100644 --- a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/EinzahlHandlerTest.java +++ b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/EinzahlHandlerTest.java @@ -17,9 +17,12 @@ ******************************************************************************/ package de.tudarmstadt.ukp.jwktl.parser.de.components.nountable; +import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryPage; import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryWordForm; import de.tudarmstadt.ukp.jwktl.api.util.GrammaticalGender; import de.tudarmstadt.ukp.jwktl.api.util.GrammaticalNumber; +import de.tudarmstadt.ukp.jwktl.parser.de.components.DEEntryFactory; +import de.tudarmstadt.ukp.jwktl.parser.util.ParsingContext; import junit.framework.TestCase; public class EinzahlHandlerTest extends TestCase { @@ -27,69 +30,71 @@ public class EinzahlHandlerTest extends TestCase { private DEWordFormNounTableHandler nounTableHandler; private GenusHandler genusHandler; private EinzahlHandler einzahlHandler; + private ParsingContext parsingContext; @Override protected void setUp() throws Exception { nounTableHandler = new DEWordFormNounTableHandler(); genusHandler = new GenusHandler(nounTableHandler); einzahlHandler = new EinzahlHandler(nounTableHandler); + parsingContext = new ParsingContext(new WiktionaryPage(), new DEEntryFactory()); } public void testCanHandle() { - assertFalse(einzahlHandler.canHandle(null, null, null, null)); - assertFalse(einzahlHandler.canHandle("Wer oder was?", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl)", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl 1)", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl 2)", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl 3)", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl 4)", null, null, null)); - assertFalse(einzahlHandler.canHandle("Wer oder was? (Einzahl 5)", null, null, null)); + assertFalse(einzahlHandler.canHandle(null, null, null, parsingContext)); + assertFalse(einzahlHandler.canHandle("Wer oder was?", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl)", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl 1)", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl 2)", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl 3)", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Einzahl 4)", null, null, parsingContext)); + assertFalse(einzahlHandler.canHandle("Wer oder was? (Einzahl 5)", null, null, parsingContext)); } public void testEinzahlWithGenus() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus", "m", wordForm, null); - einzahlHandler.handle("Wer oder was? (Einzahl)", "test", wordForm, null); + genusHandler.handle("Genus", "m", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Einzahl)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(GrammaticalGender.MASCULINE, wordForm.getGender()); } public void testEinzahlWithGenus_1() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 1", "n", wordForm, null); - einzahlHandler.handle("Wer oder was? (Einzahl)", "test", wordForm, null); + genusHandler.handle("Genus 1", "n", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Einzahl)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(GrammaticalGender.NEUTER, wordForm.getGender()); } public void testEinzahl_1WithGenus_1() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 1", "f", wordForm, null); - einzahlHandler.handle("Wer oder was? (Einzahl 1)", "test", wordForm, null); + genusHandler.handle("Genus 1", "f", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Einzahl 1)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(GrammaticalGender.FEMININE, wordForm.getGender()); } public void testEinzahl_2WithGenus_2() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 2", "x", wordForm, null); - einzahlHandler.handle("Wer oder was? (Einzahl 2)", "test", wordForm, null); + genusHandler.handle("Genus 2", "x", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Einzahl 2)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testEinzahl_3WithGenus_3() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 3", "m", wordForm, null); - einzahlHandler.handle("Wer oder was? (Einzahl 3)", "test", wordForm, null); + genusHandler.handle("Genus 3", "m", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Einzahl 3)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(GrammaticalGender.MASCULINE, wordForm.getGender()); } public void testEinzahl_3WithGenus_2() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 2", "m", wordForm, null); - einzahlHandler.handle("Wer oder was? (Einzahl 3)", "test", wordForm, null); + genusHandler.handle("Genus 2", "m", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Einzahl 3)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertNull(wordForm.getGender()); } @@ -97,8 +102,8 @@ public void testEinzahl_3WithGenus_2() { public void testEinzahl_4WithGenus_4() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 4", "n", wordForm, null); - einzahlHandler.handle("Wer oder was? (Einzahl 4)", "test", wordForm, null); + genusHandler.handle("Genus 4", "n", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Einzahl 4)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(GrammaticalGender.NEUTER, wordForm.getGender()); } diff --git a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/GenusHandlerTest.java b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/GenusHandlerTest.java index 2758c91..3544277 100644 --- a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/GenusHandlerTest.java +++ b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/GenusHandlerTest.java @@ -17,61 +17,66 @@ ******************************************************************************/ package de.tudarmstadt.ukp.jwktl.parser.de.components.nountable; +import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryPage; +import de.tudarmstadt.ukp.jwktl.parser.de.components.DEEntryFactory; import de.tudarmstadt.ukp.jwktl.parser.de.components.DEGenderText; +import de.tudarmstadt.ukp.jwktl.parser.util.ParsingContext; import junit.framework.TestCase; public class GenusHandlerTest extends TestCase { private DEWordFormNounTableHandler nounTableHandler; private GenusHandler genusHandler; + private ParsingContext parsingContext; @Override protected void setUp() throws Exception { nounTableHandler = new DEWordFormNounTableHandler(); genusHandler = new GenusHandler(nounTableHandler); + parsingContext = new ParsingContext(new WiktionaryPage(), new DEEntryFactory()); } public void testCanHandle() { - assertFalse(genusHandler.canHandle(null, null, null, null)); - assertFalse(genusHandler.canHandle("Suneg", null, null, null)); - assertTrue(genusHandler.canHandle("Genus", null, null, null)); - assertFalse(genusHandler.canHandle("Genus ", null, null, null)); - assertFalse(genusHandler.canHandle("Genus 0", null, null, null)); - assertTrue(genusHandler.canHandle("Genus 1", null, null, null)); - assertTrue(genusHandler.canHandle("Genus 2", null, null, null)); - assertTrue(genusHandler.canHandle("Genus 3", null, null, null)); - assertTrue(genusHandler.canHandle("Genus 4", null, null, null)); - assertFalse(genusHandler.canHandle("Genus 4.5", null, null, null)); - assertFalse(genusHandler.canHandle("Genus 5", null, null, null)); + assertFalse(genusHandler.canHandle(null, null, null, parsingContext)); + assertFalse(genusHandler.canHandle("Suneg", null, null, parsingContext)); + assertTrue(genusHandler.canHandle("Genus", null, null, parsingContext)); + assertFalse(genusHandler.canHandle("Genus ", null, null, parsingContext)); + assertFalse(genusHandler.canHandle("Genus 0", null, null, parsingContext)); + assertTrue(genusHandler.canHandle("Genus 1", null, null, parsingContext)); + assertTrue(genusHandler.canHandle("Genus 2", null, null, parsingContext)); + assertTrue(genusHandler.canHandle("Genus 3", null, null, parsingContext)); + assertTrue(genusHandler.canHandle("Genus 4", null, null, parsingContext)); + assertFalse(genusHandler.canHandle("Genus 4.5", null, null, parsingContext)); + assertFalse(genusHandler.canHandle("Genus 5", null, null, parsingContext)); } public void testGenus() { - genusHandler.handle("Genus", "m", null, null); + genusHandler.handle("Genus", "m", null, parsingContext); assertEquals(DEGenderText.M, nounTableHandler.getGenusByIndex(1)); assertNull(nounTableHandler.getGenusByIndex(2)); } public void testGenus1() { - genusHandler.handle("Genus 1", "n", null, null); + genusHandler.handle("Genus 1", "n", null, parsingContext); assertEquals(DEGenderText.N, nounTableHandler.getGenusByIndex(1)); assertNull(nounTableHandler.getGenusByIndex(2)); } public void testGenus2() { - genusHandler.handle("Genus 2", "pl", null, null); + genusHandler.handle("Genus 2", "pl", null, parsingContext); assertNull(nounTableHandler.getGenusByIndex(1)); assertEquals(DEGenderText.PL, nounTableHandler.getGenusByIndex(2)); assertNull(nounTableHandler.getGenusByIndex(3)); } public void testGenus3() { - genusHandler.handle("Genus 3", "0", null, null); + genusHandler.handle("Genus 3", "0", null, parsingContext); assertNull(nounTableHandler.getGenusByIndex(2)); assertEquals(DEGenderText._0, nounTableHandler.getGenusByIndex(3)); assertNull(nounTableHandler.getGenusByIndex(4)); } public void testGenus4() { - genusHandler.handle("Genus 4", "x", null, null); + genusHandler.handle("Genus 4", "x", null, parsingContext); assertNull(nounTableHandler.getGenusByIndex(3)); assertEquals(DEGenderText.X, nounTableHandler.getGenusByIndex(4)); } diff --git a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/MehrzahlHandlerTest.java b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/MehrzahlHandlerTest.java index 0716702..e3baac6 100644 --- a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/MehrzahlHandlerTest.java +++ b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/MehrzahlHandlerTest.java @@ -17,8 +17,11 @@ ******************************************************************************/ package de.tudarmstadt.ukp.jwktl.parser.de.components.nountable; +import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryPage; import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryWordForm; import de.tudarmstadt.ukp.jwktl.api.util.GrammaticalNumber; +import de.tudarmstadt.ukp.jwktl.parser.de.components.DEEntryFactory; +import de.tudarmstadt.ukp.jwktl.parser.util.ParsingContext; import junit.framework.TestCase; public class MehrzahlHandlerTest extends TestCase { @@ -26,77 +29,79 @@ public class MehrzahlHandlerTest extends TestCase { private DEWordFormNounTableHandler nounTableHandler; private GenusHandler genusHandler; private MehrzahlHandler einzahlHandler; + private ParsingContext parsingContext; @Override protected void setUp() throws Exception { nounTableHandler = new DEWordFormNounTableHandler(); genusHandler = new GenusHandler(nounTableHandler); einzahlHandler = new MehrzahlHandler(nounTableHandler); + parsingContext = new ParsingContext(new WiktionaryPage(), new DEEntryFactory()); } public void testCanHandle() { - assertFalse(einzahlHandler.canHandle(null, null, null, null)); - assertFalse(einzahlHandler.canHandle("Wer oder was?", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl)", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 1)", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 2)", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 3)", null, null, null)); - assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 4)", null, null, null)); - assertFalse(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 5)", null, null, null)); + assertFalse(einzahlHandler.canHandle(null, null, null, parsingContext)); + assertFalse(einzahlHandler.canHandle("Wer oder was?", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl)", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 1)", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 2)", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 3)", null, null, parsingContext)); + assertTrue(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 4)", null, null, parsingContext)); + assertFalse(einzahlHandler.canHandle("Wer oder was? (Mehrzahl 5)", null, null, parsingContext)); } public void testMehrzahlWithGenus() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus", "m", wordForm, null); - einzahlHandler.handle("Wer oder was? (Mehrzahl)", "test", wordForm, null); + genusHandler.handle("Genus", "m", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Mehrzahl)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testMehrzahlWithGenus_1() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 1", "n", wordForm, null); - einzahlHandler.handle("Wer oder was? (Mehrzahl)", "test", wordForm, null); + genusHandler.handle("Genus 1", "n", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Mehrzahl)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testMehrzahl_1WithGenus_1() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 1", "f", wordForm, null); - einzahlHandler.handle("Wer oder was? (Mehrzahl 1)", "test", wordForm, null); + genusHandler.handle("Genus 1", "f", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Mehrzahl 1)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testMehrzahl_2WithGenus_2() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 2", "x", wordForm, null); - einzahlHandler.handle("Wer oder was? (Mehrzahl 2)", "test", wordForm, null); + genusHandler.handle("Genus 2", "x", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Mehrzahl 2)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testMehrzahl_3WithGenus_3() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 3", "m", wordForm, null); - einzahlHandler.handle("Wer oder was? (Mehrzahl 3)", "test", wordForm, null); + genusHandler.handle("Genus 3", "m", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Mehrzahl 3)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testMehrzahl_3WithGenus_2() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 2", "m", wordForm, null); - einzahlHandler.handle("Wer oder was? (Mehrzahl 3)", "test", wordForm, null); + genusHandler.handle("Genus 2", "m", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Mehrzahl 3)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testMehrzahl_4WithGenus_4() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 4", "n", wordForm, null); - einzahlHandler.handle("Wer oder was? (Mehrzahl 4)", "test", wordForm, null); + genusHandler.handle("Genus 4", "n", wordForm, parsingContext); + einzahlHandler.handle("Wer oder was? (Mehrzahl 4)", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } diff --git a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/PluralHandlerTest.java b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/PluralHandlerTest.java index 5e5f43d..dffeae4 100644 --- a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/PluralHandlerTest.java +++ b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/PluralHandlerTest.java @@ -17,9 +17,12 @@ ******************************************************************************/ package de.tudarmstadt.ukp.jwktl.parser.de.components.nountable; +import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryPage; import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryWordForm; import de.tudarmstadt.ukp.jwktl.api.util.GrammaticalNumber; +import de.tudarmstadt.ukp.jwktl.parser.de.components.DEEntryFactory; import de.tudarmstadt.ukp.jwktl.parser.de.components.DEGenderText; +import de.tudarmstadt.ukp.jwktl.parser.util.ParsingContext; import junit.framework.TestCase; public class PluralHandlerTest extends TestCase { @@ -27,12 +30,14 @@ public class PluralHandlerTest extends TestCase { private DEWordFormNounTableHandler nounTableHandler; private GenusHandler genusHandler; private PluralHandler pluralHandler; + private ParsingContext parsingContext; @Override protected void setUp() throws Exception { nounTableHandler = new DEWordFormNounTableHandler(); genusHandler = new GenusHandler(nounTableHandler); pluralHandler = new PluralHandler(nounTableHandler); + parsingContext = new ParsingContext(new WiktionaryPage(), new DEEntryFactory()); } protected static final String PLURAL_PATTERN = @@ -65,79 +70,79 @@ protected void setUp() throws Exception { public void testCanHandle() { - assertFalse(pluralHandler.canHandle(null, null, null, null)); - assertFalse(pluralHandler.canHandle("Larulp", null, null, null)); - assertTrue(pluralHandler.canHandle("Plural", null, null, null)); - assertFalse(pluralHandler.canHandle("Plural ", null, null, null)); + assertFalse(pluralHandler.canHandle(null, null, null, parsingContext)); + assertFalse(pluralHandler.canHandle("Larulp", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle("Plural", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle("Plural ", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle("PLURAL", null, null, null)); - assertFalse(pluralHandler.canHandle(" PLURAL", null, null, null)); - assertFalse(pluralHandler.canHandle("PLURAL ", null, null, null)); + assertTrue(pluralHandler.canHandle("PLURAL", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle(" PLURAL", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle("PLURAL ", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle(" Plural", null, null, null)); - assertFalse(pluralHandler.canHandle(" Plural ", null, null, null)); + assertTrue(pluralHandler.canHandle(" Plural", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle(" Plural ", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle(" Plural*", null, null, null)); - assertFalse(pluralHandler.canHandle("Plural*", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural**", null, null, null)); - assertFalse(pluralHandler.canHandle("Plural**", null, null, null)); + assertTrue(pluralHandler.canHandle(" Plural*", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle("Plural*", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural**", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle("Plural**", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle(" Plural?", null, null, null)); - assertFalse(pluralHandler.canHandle("Plural? ", null, null, null)); - assertFalse(pluralHandler.canHandle(" Plural? ", null, null, null)); + assertTrue(pluralHandler.canHandle(" Plural?", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle("Plural? ", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle(" Plural? ", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle(" Plural *", null, null, null)); - assertFalse(pluralHandler.canHandle("Plural *", null, null, null)); + assertTrue(pluralHandler.canHandle(" Plural *", null, null, parsingContext)); + assertFalse(pluralHandler.canHandle("Plural *", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle(" Plural 1", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 2", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 3", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 4", null, null, null)); + assertTrue(pluralHandler.canHandle(" Plural 1", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 2", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 3", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 4", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle(" Plural 1*", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 2*", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 3*", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 4*", null, null, null)); + assertTrue(pluralHandler.canHandle(" Plural 1*", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 2*", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 3*", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 4*", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle(" Plural 1**", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 2**", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 3**", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural 4**", null, null, null)); + assertTrue(pluralHandler.canHandle(" Plural 1**", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 2**", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 3**", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural 4**", null, null, parsingContext)); - assertTrue(pluralHandler.canHandle(" Plural* 1", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural* 2", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural* 3", null, null, null)); - assertTrue(pluralHandler.canHandle(" Plural* 4", null, null, null)); + assertTrue(pluralHandler.canHandle(" Plural* 1", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural* 2", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural* 3", null, null, parsingContext)); + assertTrue(pluralHandler.canHandle(" Plural* 4", null, null, parsingContext)); } public void testPluralWithGenus() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus", "m", wordForm, null); - pluralHandler.handle("Nominativ Plural", "test", wordForm, null); + genusHandler.handle("Genus", "m", wordForm, parsingContext); + pluralHandler.handle("Nominativ Plural", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testPLURALWithGenus_1() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 1", "n", wordForm, null); - pluralHandler.handle("PLURAL", "test", wordForm, null); + genusHandler.handle("Genus 1", "n", wordForm, parsingContext); + pluralHandler.handle("PLURAL", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testPlural_2_SternWithGenus_2() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 2", "f", wordForm, null); - pluralHandler.handle("Nominativ Plural 2*", "test", wordForm, null); + genusHandler.handle("Genus 2", "f", wordForm, parsingContext); + pluralHandler.handle("Nominativ Plural 2*", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertNull(wordForm.getGender()); } public void testPlural_3_Stern_SternWithGenus_3() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 3", "x", wordForm, null); - pluralHandler.handle("Nominativ Plural 3**", "test", wordForm, null); + genusHandler.handle("Genus 3", "x", wordForm, parsingContext); + pluralHandler.handle("Nominativ Plural 3**", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertEquals(DEGenderText.X, nounTableHandler.getGenusByIndex(3)); assertNull(wordForm.getGender()); @@ -145,8 +150,8 @@ public void testPlural_3_Stern_SternWithGenus_3() { public void testPlural_Stern_4WithGenus_4() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 4", "pl", wordForm, null); - pluralHandler.handle("Nominativ Plural* 4", "test", wordForm, null); + genusHandler.handle("Genus 4", "pl", wordForm, parsingContext); + pluralHandler.handle("Nominativ Plural* 4", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.PLURAL, wordForm.getNumber()); assertEquals(DEGenderText.PL, nounTableHandler.getGenusByIndex(4)); assertNull(wordForm.getGender()); diff --git a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/SingularHandlerTest.java b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/SingularHandlerTest.java index ec66535..da1c8c6 100644 --- a/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/SingularHandlerTest.java +++ b/src/test/java/de/tudarmstadt/ukp/jwktl/parser/de/components/nountable/SingularHandlerTest.java @@ -17,10 +17,13 @@ ******************************************************************************/ package de.tudarmstadt.ukp.jwktl.parser.de.components.nountable; +import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryPage; import de.tudarmstadt.ukp.jwktl.api.entry.WiktionaryWordForm; import de.tudarmstadt.ukp.jwktl.api.util.GrammaticalGender; import de.tudarmstadt.ukp.jwktl.api.util.GrammaticalNumber; +import de.tudarmstadt.ukp.jwktl.parser.de.components.DEEntryFactory; import de.tudarmstadt.ukp.jwktl.parser.de.components.DEGenderText; +import de.tudarmstadt.ukp.jwktl.parser.util.ParsingContext; import junit.framework.TestCase; public class SingularHandlerTest extends TestCase { @@ -28,88 +31,90 @@ public class SingularHandlerTest extends TestCase { private DEWordFormNounTableHandler nounTableHandler; private GenusHandler genusHandler; private SingularHandler singularHandler; + private ParsingContext parsingContext; @Override protected void setUp() throws Exception { nounTableHandler = new DEWordFormNounTableHandler(); genusHandler = new GenusHandler(nounTableHandler); singularHandler = new SingularHandler(nounTableHandler); + parsingContext = new ParsingContext(new WiktionaryPage(), new DEEntryFactory()); } public void testCanHandle() { - assertFalse(singularHandler.canHandle(null, null, null, null)); - assertFalse(singularHandler.canHandle("Ralugnis", null, null, null)); - assertTrue(singularHandler.canHandle("Singular", null, null, null)); - assertFalse(singularHandler.canHandle("Singular ", null, null, null)); + assertFalse(singularHandler.canHandle(null, null, null, parsingContext)); + assertFalse(singularHandler.canHandle("Ralugnis", null, null, parsingContext)); + assertTrue(singularHandler.canHandle("Singular", null, null, parsingContext)); + assertFalse(singularHandler.canHandle("Singular ", null, null, parsingContext)); - assertTrue(singularHandler.canHandle("SINGULAR", null, null, null)); - assertFalse(singularHandler.canHandle(" SINGULAR", null, null, null)); - assertFalse(singularHandler.canHandle("SINGULAR ", null, null, null)); + assertTrue(singularHandler.canHandle("SINGULAR", null, null, parsingContext)); + assertFalse(singularHandler.canHandle(" SINGULAR", null, null, parsingContext)); + assertFalse(singularHandler.canHandle("SINGULAR ", null, null, parsingContext)); - assertTrue(singularHandler.canHandle(" Singular", null, null, null)); - assertFalse(singularHandler.canHandle(" Singular ", null, null, null)); + assertTrue(singularHandler.canHandle(" Singular", null, null, parsingContext)); + assertFalse(singularHandler.canHandle(" Singular ", null, null, parsingContext)); - assertTrue(singularHandler.canHandle(" Singular*", null, null, null)); - assertFalse(singularHandler.canHandle("Singular*", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular**", null, null, null)); - assertFalse(singularHandler.canHandle("Singular**", null, null, null)); + assertTrue(singularHandler.canHandle(" Singular*", null, null, parsingContext)); + assertFalse(singularHandler.canHandle("Singular*", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular**", null, null, parsingContext)); + assertFalse(singularHandler.canHandle("Singular**", null, null, parsingContext)); - assertTrue(singularHandler.canHandle(" Singular?", null, null, null)); - assertFalse(singularHandler.canHandle("Singular? ", null, null, null)); - assertFalse(singularHandler.canHandle(" Singular? ", null, null, null)); + assertTrue(singularHandler.canHandle(" Singular?", null, null, parsingContext)); + assertFalse(singularHandler.canHandle("Singular? ", null, null, parsingContext)); + assertFalse(singularHandler.canHandle(" Singular? ", null, null, parsingContext)); - assertTrue(singularHandler.canHandle(" Singular *", null, null, null)); - assertFalse(singularHandler.canHandle("Singular *", null, null, null)); + assertTrue(singularHandler.canHandle(" Singular *", null, null, parsingContext)); + assertFalse(singularHandler.canHandle("Singular *", null, null, parsingContext)); - assertTrue(singularHandler.canHandle(" Singular 1", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 2", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 3", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 4", null, null, null)); + assertTrue(singularHandler.canHandle(" Singular 1", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 2", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 3", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 4", null, null, parsingContext)); - assertTrue(singularHandler.canHandle(" Singular 1*", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 2*", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 3*", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 4*", null, null, null)); + assertTrue(singularHandler.canHandle(" Singular 1*", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 2*", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 3*", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 4*", null, null, parsingContext)); - assertTrue(singularHandler.canHandle(" Singular 1**", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 2**", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 3**", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular 4**", null, null, null)); + assertTrue(singularHandler.canHandle(" Singular 1**", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 2**", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 3**", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular 4**", null, null, parsingContext)); - assertTrue(singularHandler.canHandle(" Singular* 1", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular* 2", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular* 3", null, null, null)); - assertTrue(singularHandler.canHandle(" Singular* 4", null, null, null)); + assertTrue(singularHandler.canHandle(" Singular* 1", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular* 2", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular* 3", null, null, parsingContext)); + assertTrue(singularHandler.canHandle(" Singular* 4", null, null, parsingContext)); } public void testSingularWithGenus() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus", "m", wordForm, null); - singularHandler.handle("Nominativ Singular", "test", wordForm, null); + genusHandler.handle("Genus", "m", wordForm, parsingContext); + singularHandler.handle("Nominativ Singular", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(GrammaticalGender.MASCULINE, wordForm.getGender()); } public void testSINGULARWithGenus_1() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 1", "n", wordForm, null); - singularHandler.handle("SINGULAR", "test", wordForm, null); + genusHandler.handle("Genus 1", "n", wordForm, parsingContext); + singularHandler.handle("SINGULAR", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(GrammaticalGender.NEUTER, wordForm.getGender()); } public void testSingular_2_SternWithGenus_2() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 2", "f", wordForm, null); - singularHandler.handle("Nominativ Singular 2*", "test", wordForm, null); + genusHandler.handle("Genus 2", "f", wordForm, parsingContext); + singularHandler.handle("Nominativ Singular 2*", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(GrammaticalGender.FEMININE, wordForm.getGender()); } public void testSingular_3_Stern_SternWithGenus_3() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 3", "x", wordForm, null); - singularHandler.handle("Nominativ Singular 3**", "test", wordForm, null); + genusHandler.handle("Genus 3", "x", wordForm, parsingContext); + singularHandler.handle("Nominativ Singular 3**", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(DEGenderText.X, nounTableHandler.getGenusByIndex(3)); assertNull(wordForm.getGender()); @@ -117,8 +122,8 @@ public void testSingular_3_Stern_SternWithGenus_3() { public void testSingular_Stern_4WithGenus_4() { WiktionaryWordForm wordForm = new WiktionaryWordForm("test"); - genusHandler.handle("Genus 4", "pl", wordForm, null); - singularHandler.handle("Nominativ Singular* 4", "test", wordForm, null); + genusHandler.handle("Genus 4", "pl", wordForm, parsingContext); + singularHandler.handle("Nominativ Singular* 4", "test", wordForm, parsingContext); assertEquals(GrammaticalNumber.SINGULAR, wordForm.getNumber()); assertEquals(DEGenderText.PL, nounTableHandler.getGenusByIndex(4)); assertNull(wordForm.getGender()); diff --git a/src/test/resources/articles-de/Apfelschorle.txt b/src/test/resources/articles-de/Apfelschorle.txt new file mode 100644 index 0000000..b500ac8 --- /dev/null +++ b/src/test/resources/articles-de/Apfelschorle.txt @@ -0,0 +1,71 @@ +== Apfelschorle ({{Sprache|Deutsch}}) == +=== {{Wortart|Substantiv|Deutsch}}, {{fn}} === + +{{Deutsch Substantiv Übersicht +|Genus=n +|Nominativ Singular=Apfelschorle +|Nominativ Plural=Apfelschorles +|Genitiv Singular=Apfelschorles +|Genitiv Plural=Apfelschorles +|Dativ Singular=Apfelschorle +|Dativ Plural=Apfelschorles +|Akkusativ Singular=Apfelschorle +|Akkusativ Plural=Apfelschorles +}} + +{{Deutsch Substantiv Übersicht +|Genus=f +|Nominativ Singular=Apfelschorle +|Nominativ Plural=Apfelschorlen +|Genitiv Singular=Apfelschorle +|Genitiv Plural=Apfelschorlen +|Dativ Singular=Apfelschorle +|Dativ Plural=Apfelschorlen +|Akkusativ Singular=Apfelschorle +|Akkusativ Plural=Apfelschorlen +}} + +{{Anmerkung}} +:''Genus:'' Das Substantiv ''Apfelschorle'' wird in der Regel als weiblich betrachtet und entsprechend gebeugt. Selten kommt auch neutrales Genus vor, landschaftlich gebräuchlich ist das maskuline Geschlecht. + +{{Worttrennung}} +:Ap·fel·schor·le, {{Pl.}} Ap·fel·schor·len (Ap·fel·schor·les) + +{{Aussprache}} +:{{IPA}} {{Lautschrift|ˈapfl̩ˌʃɔʁlə}} +:{{Hörbeispiele}} {{Audio|De-Apfelschorle.ogg}} + +{{Bedeutungen}} +:[1] Mischgetränk, das aus [[Apfelsaft]] und [[Mineralwasser]] hergestellt wird + +{{Herkunft}} +:[[Determinativkompositum]], zusammengesetzt aus ''[[Apfel]]'' und ''[[Schorle]]'' + +{{Synonyme}} +:[1] [[Apfelsaftschorle]], ''in Österreich:'' [[Apfelsaft gespritzt]], [[Obi gespritzt]] + +{{Oberbegriffe}} +:[1] [[Getränk]] + +{{Beispiele}} +:[1] „Ich habe etwa zwei Liter ''Apfelschorle'' im Ziel zu mir genommen, dazu nochmal einen Liter Joghurtdrinks.“<ref>Internetbeleg</ref> + +{{Charakteristische Wortkombinationen}} +:[1] eine ~ [[trinken]] + +==== {{Übersetzungen}} ==== +{{Ü-Tabelle|Ü-links= +*{{en}}: [1] {{Ü|en|apple spritzer}}, {{Ü|en|apple juice spritzer}}, {{Ü|en|appletiser}} +*{{it}}: [1] ''(keine wörtliche Übersetzung:)'' una bevanda fatta da succo di mele ed acqua gassata +|Ü-rechts= +*{{es}}: [1] ''(keine wörtliche Übersetzung:)'' una bebida hecha de zumo de manzana y agua mineral +*{{cs}}: [1] {{Ü|cs|jablečný střik}} {{m}} +}} + +{{Referenzen}} +:[1] {{Wikipedia|Apfelschorle}} +:[1] {{Ref-DWDS|Apfelschorle}} +:[1] {{Ref-Canoo|Apfelschorle}} +:[1] {{Ref-UniLeipzig|Apfelschorle}} + +{{Quellen}} \ No newline at end of file