packages feed

minimorph 0.1.0.0 → 0.1.1.0

raw patch · 3 files changed

+28/−7 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ NLP.Minimorph.Number: Plural :: Number
+ NLP.Minimorph.Number: SP :: a -> a -> SingPlu a
+ NLP.Minimorph.Number: Singular :: Number
+ NLP.Minimorph.Number: data Number
+ NLP.Minimorph.Number: data SingPlu a
+ NLP.Minimorph.Number: fromSP :: Number -> SingPlu a -> a
+ NLP.Minimorph.Number: instance Eq Number
+ NLP.Minimorph.Number: instance Eq a => Eq (SingPlu a)
+ NLP.Minimorph.Number: instance Show Number
+ NLP.Minimorph.Number: instance Show a => Show (SingPlu a)
+ NLP.Minimorph.Number: pl :: SingPlu a -> a
+ NLP.Minimorph.Number: sg :: SingPlu a -> a

Files

NLP/Minimorph/English.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE ViewPatterns, OverloadedStrings #-} -- TODO : learn how to use Functional Morphology instead--- http://www.paulnoll.com/Books/Clear-English/English-plurals-1.html  -- | Module    : NLP.Minimorph.English -- Copyright   : 2012 Eric Kow (Computational Linguistics Ltd.)@@ -60,6 +59,8 @@ -- > defaultNounPlural "boy"    == "boys" -- > defaultNounPlural "spy"    == "spies" -- > defaultNounPlural "thesis" == "theses"+--+-- http://www.paulnoll.com/Books/Clear-English/English-plurals-1.html defaultNounPlural :: Text -> Text defaultNounPlural x     | "is" `T.isSuffixOf` x = thesis@@ -98,13 +99,16 @@ --   > indefiniteDet "egg"  == "an" --   > indefiniteDet "ewe"  == "a" --   > indefiniteDet "ewok" == "an"+--   > indefiniteDet "8th"  == "an" indefiniteDet :: Text -> Text indefiniteDet (T.toLower -> t) =     if useAn then "an" else "a"   where-    useAn = case T.uncons t of-                Just (h,_) -> isVowel h `butNot` hasSemivowelPrefix t-                Nothing    -> False+    useAn  = t `elem` [ "11", "11th" ] || useAn'+    useAn' = case T.uncons t of+                Just ('8',_) -> True+                Just (h,_)   -> isVowel h `butNot` hasSemivowelPrefix t+                Nothing      -> False     x `butNot` y = x && not y  -- | Ends with a sh sound@@ -121,9 +125,8 @@ hasCySuffix _ = False  -- | Is a vowel---   (this includes @'1'@ and @'8'@ because of @"one"@ and @"eight"@) isVowel :: Char -> Bool-isVowel = (`elem` "aeiouAEIOU18")+isVowel = (`elem` "aeiouAEIOU")  -- | Is a consonant isConsonant :: Char -> Bool
+ NLP/Minimorph/Number.hs view
@@ -0,0 +1,17 @@+module NLP.Minimorph.Number where++import Data.Text ( Text )++-- | Singular and Plural+data SingPlu a = SP+    { sg :: a+    , pl :: a+    }+  deriving (Show, Eq)++data Number = Singular | Plural+  deriving (Eq, Show)++fromSP :: Number -> SingPlu a -> a+fromSP Singular = sg+fromSP Plural   = pl
minimorph.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                minimorph-version:             0.1.0.0+version:             0.1.1.0 synopsis:            English spelling functions with an emphasis on simplicity. description:         A set of simplistic functions capturing the more regular                      parts of English spelling (for generation, not parsing).@@ -29,6 +29,7 @@  library   exposed-modules:     NLP.Minimorph.English+                       NLP.Minimorph.Number                        NLP.Minimorph.Util   -- other-modules:          build-depends:       base < 5