]> gitweb.factorcode.org Git - factor.git/commitdiff
english, help.markup, porter-stemmer: add vowels and vowel?
authorAlexander Ilin <alex.ilin@protonmail.com>
Sat, 17 Dec 2022 13:36:59 +0000 (14:36 +0100)
committerAlexander Ilin <alex.ilin@protonmail.com>
Wed, 21 Dec 2022 08:42:07 +0000 (09:42 +0100)
basis/english/english.factor
basis/help/markup/markup.factor
basis/porter-stemmer/porter-stemmer.factor

index 2d70d0ff41651f1444e8d84ee0cd46649643b127..13fd1d6ecece6ed99f76ec4d118332f32bcecd90 100644 (file)
@@ -106,6 +106,11 @@ CONSTANT: plural-to-singular $[ singular-to-plural [ swap ] assoc-map ]
 
 PRIVATE>
 
+CONSTANT: vowels "aeiou"
+
+: vowel? ( ch -- ? )
+    vowels member? ; inline
+
 : singularize ( word -- singular )
     dup >lower {
         { [ dup empty? ] [ ] }
@@ -114,9 +119,7 @@ PRIVATE>
         { [ dup "s" tail? not ] [ ] }
         {
             [
-                dup "ies" ?tail [
-                    last "aeiou" member? not
-                ] [ drop f ] if
+                dup "ies" ?tail [ last vowel? not ] [ drop f ] if
             ] [ 3 head* "y" append ]
         }
         { [ dup "es" tail? ] [ 2 head* ] }
@@ -130,9 +133,7 @@ PRIVATE>
         { [ singular-to-plural ?at ] [ ] }
         {
             [
-                dup "y" ?tail [
-                    last "aeiou" member? not
-                ] [ drop f ] if
+                dup "y" ?tail [ last vowel? not ] [ drop f ] if
             ] [ but-last "ies" append ]
         }
         {
@@ -161,7 +162,7 @@ PRIVATE>
     ] when ;
 
 : a/an ( word -- article )
-    [ first ] [ length ] bi 1 = "afhilmnorsx" "aeiou" ?
+    [ first ] [ length ] bi 1 = "afhilmnorsx" vowels ?
     member? "an" "a" ? ;
 
 : ?plural-article ( word -- article )
index 9f237b31be85970a6fe92f55fd2ffae146dd85a7..a92c2d64b8410d905beefcf3ab570a30571d715f 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs combinators compiler.units
-definitions.icons effects hashtables help.stylesheet help.topics
-io io.styles kernel make math namespaces present prettyprint
-prettyprint.stylesheet quotations see sequences
+definitions.icons effects english hashtables help.stylesheet
+help.topics io io.styles kernel make math namespaces present
+prettyprint prettyprint.stylesheet quotations see sequences
 sequences.private sets sorting splitting strings urls vocabs
 words words.symbol ;
 FROM: prettyprint.sections => with-pprint ;
@@ -340,7 +340,7 @@ ALIAS: $slot $snippet
 
 : a/an ( str -- str )
     [ first ] [ length ] bi 1 =
-    "afhilmnorsx" "aeiou" ? member? "an" "a" ? ;
+    "afhilmnorsx" vowels ? member? "an" "a" ? ;
 
 GENERIC: ($instance) ( element -- )
 
index 4214e67cd0e7e24c5af2f37f2d53019dd7895ea3..cd4abdcdf53ac56db2db32588718dd338a6751f5 100644 (file)
@@ -1,8 +1,9 @@
-USING: combinators kernel math parser sequences splitting ;
+USING: combinators english kernel math parser sequences
+splitting ;
 IN: porter-stemmer
 
 : consonant? ( i str -- ? )
-    2dup nth dup "aeiou" member? [
+    2dup nth dup vowel? [
         3drop f
     ] [
         CHAR: y = [