[FOray-commit] SF.net SVN: foray:[14942] trunk/foray/foray-orthograp hy/src
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2026-07-29 00:02:49
|
Revision: 14942
http://sourceforge.net/p/foray/code/14942
Author: victormote
Date: 2026-07-29 00:02:47 +0000 (Wed, 29 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/java/org/foray/orthography/StringWordTests.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_ier.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_Factory.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Replace_y_by_i.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_FactoryTests.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_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:34:10 UTC (rev 14941)
+++ trunk/foray/foray-orthography/src/main/data/orthographies/foray-orthography-config.xml 2026-07-29 00:02:47 UTC (rev 14942)
@@ -43,14 +43,6 @@
</match-rule-list>
<derivative-pattern-list id="eng-Latn-derivative-patterns">
- <derivative-pattern desc="ends with /-ier/, root ends with /-y/">
- <match>^([a-zæœëéöA-ZÆŒ\-‘’ ]+)ier$</match>
- <replace>$1y</replace>
- <derivative-rule>
- <adjective><extensible/></adjective>
- <derivative-type type="comparative"/>
- </derivative-rule>
- </derivative-pattern>
<derivative-pattern desc="ends with /-iest/, root ends with /-y/">
<match>^([a-zæœëéöA-ZÆŒ\-‘’ ]+)iest$</match>
<replace>$1y</replace>
@@ -92,6 +84,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_ier_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_ier.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier.java 2026-07-29 00:02:47 UTC (rev 14942)
@@ -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.Replace_y_by_i;
+
+import java.util.regex.Pattern;
+
+/**
+ * Wraps an adjective ending in "y", converting the "y" to "ier" make it comparatively greater than the lemma.
+ * For example, the English word "crazy" would be wrapped to make the word "crazier".
+ */
+public class EngLatnSuffix_ier extends InflectedWord {
+
+ /** The pattern to be matched by words with this inflection. */
+ public static final Pattern PATTERN = Pattern.compile("^(" + EngLatn.WORD_CHARS + "+)ier$");
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = 6349215976483323091L;
+
+ /** The word segment that replaces the last word segment in the wrapped word. */
+ private WordSegment4a modifiedSegment;
+
+ /**
+ * Constructor.
+ * @param wrappedWord The wrapped word.
+ */
+ public EngLatnSuffix_ier(final Word4a wrappedWord) {
+ super(wrappedWord);
+ this.modifiedSegment = new Replace_y_by_i(wrappedWord.getLastWordSegment());
+ }
+
+ @Override
+ public WordSegment4a getAppendedSegment() {
+ return EngLatn.ER_SEGMENT;
+ }
+
+ @Override
+ public WordSegment4a getModifiedSegment() {
+ return this.modifiedSegment;
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier.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_ier_Factory.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_Factory.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_Factory.java 2026-07-29 00:02:47 UTC (rev 14942)
@@ -0,0 +1,87 @@
+/*
+ * 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_ier}.
+ */
+public final class EngLatnSuffix_ier_Factory extends InflectionFactory<EngLatnSuffix_ier> {
+
+ /** The singleton instance. */
+ private static final EngLatnSuffix_ier_Factory THE_INSTANCE = new EngLatnSuffix_ier_Factory();
+
+ /**
+ * Private constructor for this singleton class.
+ */
+ private EngLatnSuffix_ier_Factory() { }
+
+ /**
+ * Returns the singleton instance.
+ * @return The singleton instance.
+ */
+ public static EngLatnSuffix_ier_Factory getInstance() {
+ return THE_INSTANCE;
+ }
+
+ @Override
+ public CharSequence findLemmaChars(final CharSequence chars) {
+ final Matcher matcher = EngLatnSuffix_ier.PATTERN.matcher(chars);
+ if (! matcher.matches()) {
+ return null;
+ }
+
+ final String lemmaChars = matcher.group(1) + "y";
+ return lemmaChars;
+ }
+
+ @Override
+ public boolean isValidLemma(final Word4a lemma) {
+ if (lemma.isOfQualifiedType(PartOfSpeech.ADJECTIVE, PosQualifier.EXTENSIBLE)) {
+ /*
+ <derivative-type type="comparative" desc="single-syllable root"/>
+ */
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected EngLatnSuffix_ier makeInstance(final Word4a lemma) {
+ return new EngLatnSuffix_ier(lemma);
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_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/Replace_y_by_i.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Replace_y_by_i.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Replace_y_by_i.java 2026-07-29 00:02:47 UTC (rev 14942)
@@ -0,0 +1,61 @@
+/*
+ * 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.orthography.inflection.ModifiedWordSegment;
+
+import org.axsl.orthography.WordSegment;
+
+/**
+ * Replaces a trailing "y" with "i" in the wrapped word segment.
+ */
+public class Replace_y_by_i extends ModifiedWordSegment {
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = 7801850814679870505L;
+
+ /**
+ * Constructor.
+ * @param wrappedSegment The wrapped segment.
+ */
+ public Replace_y_by_i(final WordSegment wrappedSegment) {
+ super(wrappedSegment);
+ }
+
+ @Override
+ public String getNormalForm() {
+ return "y";
+ }
+
+ @Override
+ public String getWrappedForm() {
+ return "i";
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/inflection/mods/Replace_y_by_i.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/StringWordTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/StringWordTests.java 2026-07-28 23:34:10 UTC (rev 14941)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/StringWordTests.java 2026-07-29 00:02:47 UTC (rev 14942)
@@ -140,11 +140,20 @@
public static final StringWord WORD_THIN = new StringWord(EXTENSIBLE_ADJECTIVE, "thin");
/** An adjective test word: thinner. */
- public static final StringWord WORD_THINNER = new StringWord(EXTENSIBLE_ADJECTIVE, "thin", "ner");
+ public static final StringWord WORD_THINNER = new StringWord(PosBuilder.ADJECTIVE, "thin", "ner");
/** An adjective test word: thinnest. */
- public static final StringWord WORD_THINNEST = new StringWord(EXTENSIBLE_ADJECTIVE, "thin", "nest");
+ public static final StringWord WORD_THINNEST = new StringWord(PosBuilder.ADJECTIVE, "thin", "nest");
+ /** An extensible adjective test word: crazy. */
+ public static final StringWord WORD_CRAZY = new StringWord(EXTENSIBLE_ADJECTIVE, "cra", "zy");
+
+ /** An adjective test word: crazier. */
+ public static final StringWord WORD_CRAZIER = new StringWord(PosBuilder.ADJECTIVE, "cra", "zi", "er");
+
+ /** An adjective test word: craziest. */
+ public static final StringWord WORD_CRAZIEST = new StringWord(PosBuilder.ADJECTIVE, "cra", "zi", "est");
+
/**
* Test of {@link StringWord#getWordComponent(int)}.
*/
Added: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_FactoryTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_FactoryTests.java (rev 0)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_FactoryTests.java 2026-07-29 00:02:47 UTC (rev 14942)
@@ -0,0 +1,80 @@
+/*
+ * 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_ier_Factory}.
+ */
+public class EngLatnSuffix_ier_FactoryTests {
+
+ /** The object under test. */
+ private EngLatnSuffix_ier_Factory out;
+
+ /** A dictionary to use for these tests. */
+ private Dictionary4a dictionary;
+
+ /**
+ * Test setup.
+ */
+ @BeforeEach
+ public void before() {
+ this.out = EngLatnSuffix_ier_Factory.getInstance();
+ this.dictionary = Mockito.mock(Dictionary4a.class);
+ Mockito.when(dictionary.getWord("crazy")).thenReturn(StringWordTests.WORD_CRAZY);
+ }
+
+ /**
+ * Test of a String for which the factory should not be able to create an instance.
+ */
+ @Test
+ public void testInvalid() {
+ AssertionsForClassTypes.assertThat(out.makeInstance("craziest", this.dictionary)).isNull();
+ }
+
+ /**
+ * Test of a String for which the factory should be able to create an instance.
+ */
+ @Test
+ public void testValid() {
+ final EngLatnSuffix_ier word = out.makeInstance("crazier", this.dictionary);
+ /* Test for instance equality. */
+ AssertionsForClassTypes.assertThat(word.getWrappedWord()).isEqualTo(StringWordTests.WORD_CRAZY);
+ assertThat(word.getActualContent().toString()).isEqualTo("crazier");
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_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_ier_Tests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_Tests.java (rev 0)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_Tests.java 2026-07-29 00:02:47 UTC (rev 14942)
@@ -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_ier}.
+ */
+public class EngLatnSuffix_ier_Tests {
+
+ /**
+ * Tests various aspects word ending in -ier.
+ */
+ @Test
+ public void test01() {
+ final StringWord word = StringWordTests.WORD_CRAZY;
+ final EngLatnSuffix_ier wrapper = new EngLatnSuffix_ier(word);
+
+ assertThat(wrapper.toString()).isEqualTo("cra-zi-er");
+ assertThat(wrapper.getNormalizedContent()).isEqualTo("crazy");
+ assertThat(wrapper.getActualContent().toString()).isEqualTo("crazier");
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/inflection/eng/EngLatnSuffix_ier_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:34:10 UTC (rev 14941)
+++ trunk/foray/foray-orthography/src/test/resources/orthography-config.xml 2026-07-29 00:02:47 UTC (rev 14942)
@@ -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_ier_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.
|