[FOray-commit] SF.net SVN: foray:[14939] 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:14:06
|
Revision: 14939
http://sourceforge.net/p/foray/code/14939
Author: victormote
Date: 2026-07-28 23:14:04 +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/test/resources/orthography-config.xml
Added Paths:
-----------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_Factory.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_ing.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_FactoryTests.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_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 17:18:45 UTC (rev 14938)
+++ trunk/foray/foray-orthography/src/main/data/orthographies/foray-orthography-config.xml 2026-07-28 23:14:04 UTC (rev 14939)
@@ -43,14 +43,6 @@
</match-rule-list>
<derivative-pattern-list id="eng-Latn-derivative-patterns">
- <derivative-pattern desc="ends with certain double consonants, then /-ing/">
- <match>^([a-zæœëéöA-ZÆŒ\-‘’ ]+)([bcdfgklmnprstvz])(\2)ing$</match>
- <replace>$1$2</replace>
- <derivative-rule>
- <verb><regular-root/></verb>
- <derivative-type type="present-participle"/>
- </derivative-rule>
- </derivative-pattern>
<derivative-pattern desc="ends with certain double consonants, then /-er/">
<match>^([a-zæœëéöA-ZÆŒ\-‘’ ]+)([d])(\2)er$</match>
<replace>$1$2</replace>
@@ -104,6 +96,7 @@
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ed_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ed2_Factory"/>
+ <derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_2c_ing_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ing_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ing2_Factory"/>
Added: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing.java 2026-07-28 23:14:04 UTC (rev 14939)
@@ -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_ing;
+
+import java.util.regex.Pattern;
+
+/**
+ * Wraps an extensible adjective that ends with a vowel and then a consonant, doubles that consonant, then adds "ing" at
+ * the end.
+ * For example, the English word "beg" would be wrapped to make the word "beg-ging".
+ */
+public class EngLatnSuffix_2c_ing extends InflectedWord {
+
+ /** The pattern to be matched by words with this inflection. */
+ public static final Pattern PATTERN = Pattern.compile("^(" + EngLatn.WORD_CHARS + "+)([bdfgklmnprstvz])(\\2)ing$");
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = -2590657455118804639L;
+
+ /**
+ * Constructor.
+ * @param wrappedWord The wrapped word.
+ */
+ public EngLatnSuffix_2c_ing(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_ing.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_ing.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_ing_Factory.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_Factory.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_Factory.java 2026-07-28 23:14:04 UTC (rev 14939)
@@ -0,0 +1,88 @@
+/*
+ * 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.inflection.InflectionFactory;
+
+import org.axsl.orthography.PartOfSpeech;
+import org.axsl.orthography.PosQualifier;
+
+import java.util.regex.Matcher;
+
+/**
+ * Factory class for {@link EngLatnSuffix_2c_ing}.
+ */
+public final class EngLatnSuffix_2c_ing_Factory extends InflectionFactory<EngLatnSuffix_2c_ing> {
+
+ /** The singleton instance. */
+ private static final EngLatnSuffix_2c_ing_Factory THE_INSTANCE = new EngLatnSuffix_2c_ing_Factory();
+
+ /**
+ * Private constructor for this singleton class.
+ */
+ private EngLatnSuffix_2c_ing_Factory() { }
+
+ /**
+ * Returns the singleton instance.
+ * @return The singleton instance.
+ */
+ public static EngLatnSuffix_2c_ing_Factory getInstance() {
+ return THE_INSTANCE;
+ }
+
+ @Override
+ public CharSequence findLemmaChars(final CharSequence chars) {
+ final Matcher matcher = EngLatnSuffix_2c_ing.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.VERB, PosQualifier.REGULAR_ROOT)) {
+ /*
+ <verb><regular-root/></verb>
+ <derivative-type type="present-participle"/>
+ */
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected EngLatnSuffix_2c_ing makeInstance(final Word4a lemma) {
+ return new EngLatnSuffix_2c_ing(lemma);
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_Factory.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/mods/Full_2c_ing.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_ing.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Full_2c_ing.java 2026-07-28 23:14:04 UTC (rev 14939)
@@ -0,0 +1,112 @@
+/*
+ * 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 "ing".
+ */
+public final class Full_2c_ing {
+
+ /** Pre-constructed instance staring with "b". */
+ private static final StringWordSegmentLatin1 B_INSTANCE = new StringWordSegmentLatin1("bing");
+
+ /** Pre-constructed instance staring with "d". */
+ private static final StringWordSegmentLatin1 D_INSTANCE = new StringWordSegmentLatin1("ding");
+
+ /** Pre-constructed instance staring with "f". */
+ private static final StringWordSegmentLatin1 F_INSTANCE = new StringWordSegmentLatin1("fing");
+
+ /** Pre-constructed instance staring with "g". */
+ private static final StringWordSegmentLatin1 G_INSTANCE = new StringWordSegmentLatin1("ging");
+
+ /** Pre-constructed instance staring with "k". */
+ private static final StringWordSegmentLatin1 K_INSTANCE = new StringWordSegmentLatin1("king");
+
+ /** Pre-constructed instance staring with "l". */
+ private static final StringWordSegmentLatin1 L_INSTANCE = new StringWordSegmentLatin1("ling");
+
+ /** Pre-constructed instance staring with "m". */
+ private static final StringWordSegmentLatin1 M_INSTANCE = new StringWordSegmentLatin1("ming");
+
+ /** Pre-constructed instance staring with "n". */
+ private static final StringWordSegmentLatin1 N_INSTANCE = new StringWordSegmentLatin1("ning");
+
+ /** Pre-constructed instance staring with "p". */
+ private static final StringWordSegmentLatin1 P_INSTANCE = new StringWordSegmentLatin1("ping");
+
+ /** Pre-constructed instance staring with "r". */
+ private static final StringWordSegmentLatin1 R_INSTANCE = new StringWordSegmentLatin1("ring");
+
+ /** Pre-constructed instance staring with "s". */
+ private static final StringWordSegmentLatin1 S_INSTANCE = new StringWordSegmentLatin1("sing");
+
+ /** Pre-constructed instance staring with "t". */
+ private static final StringWordSegmentLatin1 T_INSTANCE = new StringWordSegmentLatin1("ting");
+
+ /** Pre-constructed instance staring with "v". */
+ private static final StringWordSegmentLatin1 V_INSTANCE = new StringWordSegmentLatin1("ving");
+
+ /** Pre-constructed instance staring with "z". */
+ private static final StringWordSegmentLatin1 Z_INSTANCE = new StringWordSegmentLatin1("zing");
+
+ /**
+ * Private constructor. This is a utility class that should not be instantiated.
+ */
+ private Full_2c_ing() { }
+
+ /**
+ * 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 'b': return B_INSTANCE;
+ case 'd': return D_INSTANCE;
+ case 'f': return F_INSTANCE;
+ case 'g': return G_INSTANCE;
+ case 'k': return K_INSTANCE;
+ case 'l': return L_INSTANCE;
+ case 'm': return M_INSTANCE;
+ case 'n': return N_INSTANCE;
+ case 'p': return P_INSTANCE;
+ case 'r': return R_INSTANCE;
+ case 's': return S_INSTANCE;
+ case 't': return T_INSTANCE;
+ case 'v': return V_INSTANCE;
+ case 'z': return Z_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_ing.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_ing_FactoryTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_FactoryTests.java (rev 0)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_FactoryTests.java 2026-07-28 23:14:04 UTC (rev 14939)
@@ -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_ing_Factory}.
+ */
+public class EngLatnSuffix_2c_ing_FactoryTests {
+
+ /** The object under test. */
+ private EngLatnSuffix_2c_ing_Factory out;
+
+ /** A dictionary to use for these tests. */
+ private Dictionary4a dictionary;
+
+ /**
+ * Test setup.
+ */
+ @BeforeEach
+ public void before() {
+ this.out = EngLatnSuffix_2c_ing_Factory.getInstance();
+ this.dictionary = Mockito.mock(Dictionary4a.class);
+ Mockito.when(dictionary.getWord("plan")).thenReturn(StringWordTests.WORD_PLAN);
+ }
+
+ /**
+ * Test of a String for which the factory should not be able to create an instance.
+ */
+ @Test
+ public void testInvalid() {
+ final EngLatnSuffix_2c_ing word = out.makeInstance("planned", 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_ing word = out.makeInstance("planning", this.dictionary);
+ /* Test for instance equality. */
+ AssertionsForClassTypes.assertThat(word.getWrappedWord()).isSameAs(StringWordTests.WORD_PLAN);
+ assertThat(word.getActualContent().toString()).isEqualTo("planning");
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_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_ing_Tests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_Tests.java (rev 0)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_Tests.java 2026-07-28 23:14:04 UTC (rev 14939)
@@ -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_ing}.
+ */
+public class EngLatnSuffix_2c_ing_Tests {
+
+ /**
+ * Tests for words ending in double-consonant following by "ing".
+ */
+ @Test
+ public void test01() {
+ final StringWord word = StringWordTests.WORD_PLAN;
+ final EngLatnSuffix_2c_ing wrapper = new EngLatnSuffix_2c_ing(word);
+
+ assertThat(wrapper.toString()).isEqualTo("plan-ning");
+ assertThat(wrapper.getNormalizedContent()).isEqualTo("plan");
+ assertThat(wrapper.getActualContent().toString()).isEqualTo("planning");
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_2c_ing_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 17:18:45 UTC (rev 14938)
+++ trunk/foray/foray-orthography/src/test/resources/orthography-config.xml 2026-07-28 23:14:04 UTC (rev 14939)
@@ -24,6 +24,7 @@
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ed_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ed2_Factory"/>
+ <derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_2c_ing_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ing_Factory"/>
<derivative-factory class="org.foray.orthography.inflection.eng.EngLatnSuffix_ing2_Factory"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|