[FOray-commit] SF.net SVN: foray:[14941] trunk/foray/foray-orthograp hy/src
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2026-07-28 23:34:13
|
Revision: 14941
http://sourceforge.net/p/foray/code/14941
Author: victormote
Date: 2026-07-28 23:34:10 +0000 (Tue, 28 Jul 2026)
Log Message:
-----------
Convert another XML derivative-pattern to java classes.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/data/orthographies/foray-orthography-config.xml
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_est.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_est.java
trunk/foray/foray-orthography/src/test/resources/orthography-config.xml
Added Paths:
-----------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Factory.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_er.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_FactoryTests.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Tests.java
Modified: trunk/foray/foray-orthography/src/main/data/orthographies/foray-orthography-config.xml
===================================================================
--- trunk/foray/foray-orthography/src/main/data/orthographies/foray-orthography-config.xml 2026-07-28 23:14:26 UTC (rev 14940)
+++ trunk/foray/foray-orthography/src/main/data/orthographies/foray-orthography-config.xml 2026-07-28 23:34:10 UTC (rev 14941)
@@ -43,14 +43,6 @@
</match-rule-list>
<derivative-pattern-list id="eng-Latn-derivative-patterns">
- <derivative-pattern desc="ends with certain double consonants, then /-er/">
- <match>^([a-zæœëéöA-ZÆŒ\-‘’ ]+)([d])(\2)er$</match>
- <replace>$1$2</replace>
- <derivative-rule>
- <adjective><extensible/></adjective>
- <derivative-type type="comparative"/>
- </derivative-rule>
- </derivative-pattern>
<derivative-pattern desc="ends with /-ier/, root ends with /-y/">
<match>^([a-zæœëéöA-ZÆŒ\-‘’ ]+)ier$</match>
<replace>$1y</replace>
@@ -100,6 +92,7 @@
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ing_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ing2_Factory"/>
+ <derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_2c_er_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_er_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_er2_Factory"/>
Added: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er.java 2026-07-28 23:34:10 UTC (rev 14941)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2026 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.orthography.inflection.eng;
+
+import org.foray.orthography.Word4a;
+import org.foray.orthography.WordSegment4a;
+import org.foray.orthography.inflection.InflectedWord;
+import org.foray.orthography.inflection.mods.Full_2c_er;
+
+import java.util.regex.Pattern;
+
+/**
+ * Wraps an extensible adjective that ends with a vowel and then a consonant, doubles that consonant, then adds "er" at
+ * the end to make it a comparative.
+ * For example, the English word "thin" would be wrapped to make the word "thinner".
+ */
+public class EngLatnSuffix_2c_er extends InflectedWord {
+
+ /** The pattern to be matched by words with this inflection. */
+ public static final Pattern PATTERN = Pattern.compile("^(" + EngLatn.WORD_CHARS + "+)([dgnt])(\\2)er$");
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = -3858054928625944035L;
+
+ /**
+ * Constructor.
+ * @param wrappedWord The wrapped word.
+ */
+ public EngLatnSuffix_2c_er(final Word4a wrappedWord) {
+ super(wrappedWord);
+ }
+
+ @Override
+ public WordSegment4a getAppendedSegment() {
+ final WordSegment4a lastSegment = getWrappedWord().getLastWordSegment();
+ final int lastIndex = lastSegment.length() - 1;
+ final char lastChar = lastSegment.charAt(lastIndex);
+ return Full_2c_er.getInstance(lastChar);
+ }
+
+ @Override
+ public WordSegment4a getModifiedSegment() {
+ return null;
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Factory.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Factory.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Factory.java 2026-07-28 23:34:10 UTC (rev 14941)
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2019 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.orthography.inflection.eng;
+
+import org.foray.orthography.Word4a;
+import org.foray.orthography.inflection.InflectionFactory;
+
+import org.axsl.orthography.PartOfSpeech;
+import org.axsl.orthography.PosQualifier;
+
+import java.util.regex.Matcher;
+
+/**
+ * Factory class for {@link EngLatnSuffix_2c_er}.
+ */
+public final class EngLatnSuffix_2c_er_Factory extends InflectionFactory<EngLatnSuffix_2c_er> {
+
+ /** The singleton instance. */
+ private static final EngLatnSuffix_2c_er_Factory THE_INSTANCE = new EngLatnSuffix_2c_er_Factory();
+
+ /**
+ * Private constructor for this singleton class.
+ */
+ private EngLatnSuffix_2c_er_Factory() { }
+
+ /**
+ * Returns the singleton instance.
+ * @return The singleton instance.
+ */
+ public static EngLatnSuffix_2c_er_Factory getInstance() {
+ return THE_INSTANCE;
+ }
+
+ @Override
+ public CharSequence findLemmaChars(final CharSequence chars) {
+ final Matcher matcher = EngLatnSuffix_2c_er.PATTERN.matcher(chars);
+ if (! matcher.matches()) {
+ return null;
+ }
+
+ final String lemmaChars = matcher.group(1) + matcher.group(2);
+ return lemmaChars;
+ }
+
+ @Override
+ public boolean isValidLemma(final Word4a lemma) {
+ if (lemma.isOfQualifiedType(PartOfSpeech.ADJECTIVE, PosQualifier.EXTENSIBLE)) {
+ /*
+ <adjective><extensible/></adjective>
+ <derivative-type type="comparative"/>
+ */
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected EngLatnSuffix_2c_er makeInstance(final Word4a lemma) {
+ return new EngLatnSuffix_2c_er(lemma);
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Factory.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_est.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_est.java 2026-07-28 23:14:26 UTC (rev 14940)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_est.java 2026-07-28 23:34:10 UTC (rev 14941)
@@ -43,7 +43,7 @@
public class EngLatnSuffix_2c_est extends InflectedWord {
/** The pattern to be matched by words with this inflection. */
- public static final Pattern PATTERN = Pattern.compile("^(" + EngLatn.WORD_CHARS + "+)([dn])(\\2)est$");
+ public static final Pattern PATTERN = Pattern.compile("^(" + EngLatn.WORD_CHARS + "+)([dgnt])(\\2)est$");
/** Constant needed for serialization. */
private static final long serialVersionUID = 8397674653229148700L;
Added: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_er.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_er.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_er.java 2026-07-28 23:34:10 UTC (rev 14941)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2026 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.orthography.inflection.mods;
+
+import org.foray.common.primitive.CodePointUtils;
+import org.foray.orthography.StringWordSegmentLatin1;
+import org.foray.orthography.WordSegment4a;
+
+/**
+ * Full segment composed of a single consonant following by "er".
+ */
+public final class Full_2c_er {
+
+ /** Pre-constructed instance staring with "d". */
+ private static final StringWordSegmentLatin1 D_INSTANCE = new StringWordSegmentLatin1("der");
+
+ /** Pre-constructed instance staring with "g". */
+ private static final StringWordSegmentLatin1 G_INSTANCE = new StringWordSegmentLatin1("ger");
+
+ /** Pre-constructed instance staring with "n". */
+ private static final StringWordSegmentLatin1 N_INSTANCE = new StringWordSegmentLatin1("ner");
+
+ /** Pre-constructed instance staring with "t". */
+ private static final StringWordSegmentLatin1 T_INSTANCE = new StringWordSegmentLatin1("ter");
+
+ /**
+ * Private constructor. This is a utility class that should not be instantiated.
+ */
+ private Full_2c_er() { }
+
+ /**
+ * Gets the segment instance that beings with a specified consonant.
+ * @param consonant The consonant for which the segment instance is needed.
+ * @return The segment instance for {@code consonant}.
+ */
+ public static WordSegment4a getInstance(final int consonant) {
+ switch (consonant) {
+ case 'd': return D_INSTANCE;
+ case 'g': return G_INSTANCE;
+ case 'n': return N_INSTANCE;
+ case 't': return T_INSTANCE;
+ }
+ throw new IllegalArgumentException("Unexpected leading consonant: " + CodePointUtils.toString(consonant));
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_er.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_est.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_est.java 2026-07-28 23:14:26 UTC (rev 14940)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_est.java 2026-07-28 23:34:10 UTC (rev 14941)
@@ -40,9 +40,15 @@
/** Pre-constructed instance staring with "d". */
private static final StringWordSegmentLatin1 D_INSTANCE = new StringWordSegmentLatin1("dest");
+ /** Pre-constructed instance staring with "g". */
+ private static final StringWordSegmentLatin1 G_INSTANCE = new StringWordSegmentLatin1("gest");
+
/** Pre-constructed instance staring with "n". */
private static final StringWordSegmentLatin1 N_INSTANCE = new StringWordSegmentLatin1("nest");
+ /** Pre-constructed instance staring with "t". */
+ private static final StringWordSegmentLatin1 T_INSTANCE = new StringWordSegmentLatin1("test");
+
/**
* Private constructor. This is a utility class that should not be instantiated.
*/
@@ -56,7 +62,9 @@
public static WordSegment4a getInstance(final int consonant) {
switch (consonant) {
case 'd': return D_INSTANCE;
+ case 'g': return G_INSTANCE;
case 'n': return N_INSTANCE;
+ case 't': return T_INSTANCE;
}
throw new IllegalArgumentException("Unexpected leading consonant: " + CodePointUtils.toString(consonant));
}
Added: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_FactoryTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_FactoryTests.java (rev 0)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_FactoryTests.java 2026-07-28 23:34:10 UTC (rev 14941)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2026 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.orthography.inflection.eng;
+
+import org.foray.orthography.Dictionary4a;
+import org.foray.orthography.StringWordTests;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.assertj.core.api.AssertionsForClassTypes;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+/**
+ * Tests of {@link EngLatnSuffix_2c_er_Factory}.
+ */
+public class EngLatnSuffix_2c_er_FactoryTests {
+
+ /** The object under test. */
+ private EngLatnSuffix_2c_er_Factory out;
+
+ /** A dictionary to use for these tests. */
+ private Dictionary4a dictionary;
+
+ /**
+ * Test setup.
+ */
+ @BeforeEach
+ public void before() {
+ this.out = EngLatnSuffix_2c_er_Factory.getInstance();
+ this.dictionary = Mockito.mock(Dictionary4a.class);
+ Mockito.when(dictionary.getWord("thin")).thenReturn(StringWordTests.WORD_THIN);
+ }
+
+ /**
+ * Test of a String for which the factory should not be able to create an instance.
+ */
+ @Test
+ public void testInvalid() {
+ final EngLatnSuffix_2c_er word = out.makeInstance("thinnest", this.dictionary);
+ AssertionsForClassTypes.assertThat(word).isNull();
+ }
+
+ /**
+ * Test of a String for which the factory should be able to create an instance.
+ */
+ @Test
+ public void testValid() {
+ final EngLatnSuffix_2c_er word = out.makeInstance("thinner", this.dictionary);
+ /* Test for instance equality. */
+ AssertionsForClassTypes.assertThat(word.getWrappedWord()).isSameAs(StringWordTests.WORD_THIN);
+ assertThat(word.getActualContent().toString()).isEqualTo("thinner");
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_FactoryTests.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Tests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Tests.java (rev 0)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Tests.java 2026-07-28 23:34:10 UTC (rev 14941)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2026 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.orthography.inflection.eng;
+
+import org.foray.orthography.StringWord;
+import org.foray.orthography.StringWordTests;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests of {@link EngLatnSuffix_2c_er}.
+ */
+public class EngLatnSuffix_2c_er_Tests {
+
+ /**
+ * Tests for words ending in double-consonant following by "er".
+ */
+ @Test
+ public void test01() {
+ final StringWord word = StringWordTests.WORD_THIN;
+ final EngLatnSuffix_2c_er wrapper = new EngLatnSuffix_2c_er(word);
+
+ assertThat(wrapper.toString()).isEqualTo("thin-ner");
+ assertThat(wrapper.getNormalizedContent()).isEqualTo("thin");
+ assertThat(wrapper.getActualContent().toString()).isEqualTo("thinner");
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_er_Tests.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-orthography/src/test/resources/orthography-config.xml
===================================================================
--- trunk/foray/foray-orthography/src/test/resources/orthography-config.xml 2026-07-28 23:14:26 UTC (rev 14940)
+++ trunk/foray/foray-orthography/src/test/resources/orthography-config.xml 2026-07-28 23:34:10 UTC (rev 14941)
@@ -28,6 +28,7 @@
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ing_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ing2_Factory"/>
+ <derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_2c_er_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_er_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_er2_Factory"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|