packages feed

minimorph 0.2.1.0 → 0.2.2.0

raw patch · 4 files changed

+26/−26 lines, 4 filesdep ~text

Dependency ranges changed: text

Files

NLP/Minimorph/English.hs view
@@ -1,8 +1,11 @@-{-# LANGUAGE OverloadedStrings, ViewPatterns #-}+{-# LANGUAGE ViewPatterns #-} -- TODO : learn how to use Functional Morphology instead -- |Simple default rules for English morphology module NLP.Minimorph.English where +-- Only needed for older GHC, but let's avoid CPP for this instance.+import Data.Monoid ((<>))+ import           Data.Char (isSpace, isUpper, toLower) import           Data.Text (Text) import qualified Data.Text as T@@ -100,14 +103,16 @@     | hasSibilantSuffix x   = sibilant_o     | hasCoSuffix x         = sibilant_o     | hasCySuffix x         = y_final-    | "f"  `T.isSuffixOf` x = f_final+    | "ff" `T.isSuffixOf` x = ff_final  -- quite often not the case+    | "f" `T.isSuffixOf` x  = f_final   -- but this one as well, so both needed     | otherwise             = plain   where     plain      = x            <> "s"     sibilant_o = x            <> "es"     y_final    = T.init x     <> "ies"     f_final    = T.init x     <> "ves"-    thesis     = tDropEnd 2 x <> "es"+    ff_final   = T.dropEnd 2 x <> "ves"+    thesis     = T.dropEnd 2 x <> "es"  -- | Heuristics for 3rd person singular and past participle --   for an unknown regular verb. Doubling of final consonants@@ -242,12 +247,12 @@  -- | Last two letters are a consonant and \'y\'. hasCySuffix :: Text -> Bool-hasCySuffix (T.unpack . tTakeEnd 2 -> [x, 'y']) = isConsonant x+hasCySuffix (T.unpack . T.takeEnd 2 -> [x, 'y']) = isConsonant x hasCySuffix _ = False  -- | Last two letters are a consonant and \'o\'. hasCoSuffix :: Text -> Bool-hasCoSuffix (T.unpack . tTakeEnd 2 -> [x, 'o']) = isConsonant x+hasCoSuffix (T.unpack . T.takeEnd 2 -> [x, 'o']) = isConsonant x hasCoSuffix _ = False  -- | Is a vowel.
NLP/Minimorph/Util.hs view
@@ -1,20 +1,13 @@-{-# LANGUAGE OverloadedStrings #-} -- | Text utility functions. module NLP.Minimorph.Util- ( tTakeEnd, tDropEnd, (<>), (<+>), tshow )+ ( (<+>), tshow )  where +-- Only needed for older GHC, but let's avoid CPP for this instance. import Data.Monoid ((<>))-import Data.Text (Text)-import qualified Data.Text as T --- | @tTakeEnd n t@ returns the last @n@ letters of @t@.-tTakeEnd :: Int -> Text -> Text-tTakeEnd n t = T.drop (T.length t - n) t---- | @tDropEnd n t@ drops the last @n@ letters of @t@.-tDropEnd :: Int -> Text -> Text-tDropEnd n x = T.take (T.length x - n) x+import           Data.Text (Text)+import qualified Data.Text as T  infixr 6 <+>  -- matches Monoid.<> -- | Separated by space unless one of them is empty (in which case just
minimorph.cabal view
@@ -5,7 +5,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- minor or non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.2.1.0+version:             0.2.2.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).@@ -38,18 +38,20 @@                        NLP.Minimorph.Util    build-depends:       base < 5-               ,       text+               ,       text >= 1.1.1    default-language:   Haskell2010+  default-extensions: OverloadedStrings   if impl(ghc >= 8.0)   {   default-extensions: MonoLocalBinds, ScopedTypeVariables, OverloadedStrings                       BangPatterns, RecordWildCards, NamedFieldPuns, MultiWayIf,                       LambdaCase, DefaultSignatures, InstanceSigs,-                      MonadFailDesugaring, StrictData, CPP-  ghc-options:        -Wall -Wcompat -Worphans -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-home-modules -Widentities -Wredundant-constraints+                      PatternSynonyms, StrictData, CPP+  other-extensions:   ViewPatterns+  ghc-options:        -Wall -Wcompat -Worphans -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-home-modules -Widentities -Wredundant-constraints -Wpartial-fields   ghc-options:        -Wall-missed-specialisations-  ghc-options:        -fno-ignore-asserts -fexpose-all-unfoldings -fspecialise-aggressively+  ghc-options:        -fno-ignore-asserts -fexpose-all-unfoldings -fspecialise-aggressively -fsimpl-tick-factor=200   }  test-suite test-minimorph@@ -64,13 +66,15 @@                ,       test-framework-hunit                ,       text   default-language:   Haskell2010+  default-extensions: OverloadedStrings   if impl(ghc >= 8.0)   {   default-extensions: MonoLocalBinds, ScopedTypeVariables, OverloadedStrings                       BangPatterns, RecordWildCards, NamedFieldPuns, MultiWayIf,                       LambdaCase, DefaultSignatures, InstanceSigs,-                      MonadFailDesugaring, StrictData, CPP-  ghc-options:        -Wall -Wcompat -Worphans -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-home-modules -Widentities -Wredundant-constraints+                      PatternSynonyms, StrictData, CPP+  ghc-options:        -Wall -Wcompat -Worphans -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-home-modules -Widentities -Wredundant-constraints -Wpartial-fields   ghc-options:        -Wall-missed-specialisations-  ghc-options:        -fno-ignore-asserts -fexpose-all-unfoldings -fspecialise-aggressively+  ghc-options:        -fno-ignore-asserts -fexpose-all-unfoldings -fspecialise-aggressively -fsimpl-tick-factor=200+  ghc-options:        -threaded -rtsopts   }
test/NLP/Minimorph/EnglishTest.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE OverloadedStrings #-}- module NLP.Minimorph.EnglishTest where  import           Data.Text (Text)