packages feed

minimorph 0.1.6.1 → 0.2.0.0

raw patch · 7 files changed

+63/−70 lines, 7 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: [pl] :: SingPlu a -> a
- NLP.Minimorph.Number: [sg] :: SingPlu a -> a
- NLP.Minimorph.Number: data Number
- NLP.Minimorph.Number: data SingPlu a
- NLP.Minimorph.Number: fromSP :: Number -> SingPlu a -> a
- NLP.Minimorph.Number: instance GHC.Classes.Eq NLP.Minimorph.Number.Number
- NLP.Minimorph.Number: instance GHC.Classes.Eq a => GHC.Classes.Eq (NLP.Minimorph.Number.SingPlu a)
- NLP.Minimorph.Number: instance GHC.Show.Show NLP.Minimorph.Number.Number
- NLP.Minimorph.Number: instance GHC.Show.Show a => GHC.Show.Show (NLP.Minimorph.Number.SingPlu a)
- NLP.Minimorph.Util: (<>) :: Monoid m => m -> m -> m
+ NLP.Minimorph.Util: (<>) :: Semigroup a => a -> a -> a

Files

LICENSE view
@@ -1,4 +1,5 @@-Copyright (c) 2012-2017, Computational Linguistics Ltd.+Copyright (c) 2012-2015, Computational Linguistics Ltd.+              2012-2019, Mikolaj Konarski  All rights reserved. 
NLP/Minimorph/English.hs view
@@ -1,22 +1,13 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ViewPatterns      #-}+{-# LANGUAGE OverloadedStrings, ViewPatterns #-} -- TODO : learn how to use Functional Morphology instead---- | Module    : NLP.Minimorph.English--- Copyright   : 2012 Eric Kow (Computational Linguistics Ltd.)--- License     : BSD3--- Maintainer  : eric.kow@gmail.com--- Stability   : experimental--- Portability : portable------ Simple default rules for English morphology+-- |Simple default rules for English morphology module NLP.Minimorph.English where -import           Data.Char          (toLower, isSpace, isUpper)-import           Data.Text          (Text)-import qualified Data.Text          as T+import           Data.Char (isSpace, isUpper, toLower)+import           Data.Text (Text)+import qualified Data.Text as T -import           NLP.Minimorph.Util+import NLP.Minimorph.Util  -- --------------------------------------------------------------------- -- ** Punctuation@@ -35,12 +26,14 @@ -- ** Numbers -- --------------------------------------------------------------------- --- | > cardinal 1 == "one"+-- | > cardinal 0 == "zero"+--   > cardinal 1 == "one" --   > cardinal 2 == "two"---   > cardinal 3 == "three"+--   > cardinal 10 == "ten" --   > cardinal 11 == "11" cardinal :: Int -> Text cardinal n = case n of+    0  -> "zero"     1  -> "one"     2  -> "two"     3  -> "three"@@ -73,6 +66,7 @@ --   > ordinal 42 == "42nd" ordinal :: Int -> Text ordinal n = case n of+    0  -> "zeroth"     1  -> "first"     2  -> "second"     3  -> "third"@@ -98,6 +92,7 @@ -- > defaultNounPlural "thesis" == "theses" -- -- http://www.paulnoll.com/Books/Clear-English/English-plurals-1.html+-- -- http://en.wikipedia.org/wiki/English_plural defaultNounPlural :: Text -> Text defaultNounPlural x@@ -116,7 +111,7 @@  -- | Heuristics for 3rd person singular and past participle --   for an unknown regular verb. Doubling of final consonants---   can be handled via a table of (partially) irrefular verbs.+--   can be handled via a table of (partially) irregular verbs. -- -- > defaultVerbStuff "walk"  == ("walks",  "walked") -- > defaultVerbStuff "push"  == ("pushes", "pushed")@@ -165,7 +160,7 @@ indefiniteDet t = if wantsAn t then "an" else "a"  -- | True if the indefinite determiner for a word would normally be---   'an' as opposed to 'a'.+--   \'an\' as opposed to \'a\'. wantsAn :: Text -> Bool wantsAn t_ =     if startsWithAcronym t_@@ -189,7 +184,7 @@ --   > wantsAn        "x-ray" == False --   > acronymWantsAn "x-ray" == True -----   Note that this won't do the right thing for words like @"SCUBA"@.+--   Note that this won't do the right thing for words like \"SCUBA\". --   You really have to reserve it for those separate-letter acronyms. acronymWantsAn :: Text -> Bool acronymWantsAn (T.toLower -> t) =@@ -215,7 +210,7 @@ looksLikeAcronym "" = False looksLikeAcronym x = T.all isUpper (if T.length x > 1 then T.drop 1 x else x) --- | True if the first word (separating on either - or space)+-- | True if the first word (separating on either hyphen or space) --   looks like an acronym. startsWithAcronym :: Text -> Bool startsWithAcronym =@@ -228,7 +223,7 @@ -- ** Sounds -- --------------------------------------------------------------------- --- | Ends with a sh sound.+-- | Ends with a \'sh\' sound. hasSibilantSuffix :: Text -> Bool hasSibilantSuffix x = any (`T.isSuffixOf` x) ["x","s","ch","sh","z","j"] @@ -236,7 +231,7 @@ hasSemivowelPrefix :: Text -> Bool hasSemivowelPrefix ls = any (`T.isPrefixOf` ls) ["y","w","eu","ewe"] --- | Starts with a vowel-y U sound+-- | Starts with a vowel-y \'U\' sound hasVowel_U_Prefix :: Text -> Bool hasVowel_U_Prefix t =     case T.unpack t of@@ -245,12 +240,12 @@         ('u':c:v:_) -> not (isConsonant c && isVowel v)         _           -> False --- | Last two letters are a consonant and 'y'.+-- | Last two letters are a consonant and \'y\'. hasCySuffix :: Text -> Bool hasCySuffix (T.unpack . tTakeEnd 2 -> [x, 'y']) = isConsonant x hasCySuffix _ = False --- | Last two letters are a consonant and 'o'.+-- | Last two letters are a consonant and \'o\'. hasCoSuffix :: Text -> Bool hasCoSuffix (T.unpack . tTakeEnd 2 -> [x, 'o']) = isConsonant x hasCoSuffix _ = False@@ -265,8 +260,8 @@ --   > isLetterWithInitialVowelSound 'r' == True --   > isLetterWithInitialVowelSound 'k' == False -----   (In the above, @'r'@ is pronounced @"are"@, but @'k'@ is pronounced---   @"kay"@.)+--   (In the above, \'r\' is pronounced \"are\", but \'k\' is pronounced+--   \"kay\".) isLetterWithInitialVowelSound :: Char -> Bool isLetterWithInitialVowelSound = (`elem` ("aeiofhlmnrsx" :: String)) . toLower 
− NLP/Minimorph/Number.hs
@@ -1,17 +0,0 @@-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
NLP/Minimorph/Util.hs view
@@ -1,12 +1,5 @@ {-# LANGUAGE OverloadedStrings #-}--- | Module    : NLP.Minimorph.Util--- Copyright   : 2012 Eric Kow (Computational Linguistics Ltd.)--- License     : BSD3--- Maintainer  : eric.kow@gmail.com--- Stability   : experimental--- Portability : portable------ Text utility functions.+-- | Text utility functions. module NLP.Minimorph.Util  ( tTakeEnd, tDropEnd, (<>), (<+>), tshow )  where@@ -31,6 +24,6 @@           | T.null t2 = t1           | otherwise = t1 <> " " <> t2 --- | Show a value in Text format.+-- | Show a value in `Text` format. tshow :: Show a => a -> Text tshow = T.pack . show
minimorph.cabal view
@@ -1,8 +1,11 @@--- Initial minimorph.cabal generated by cabal init.  For further--- documentation, see http://haskell.org/cabal/users-guide/- name:                minimorph-version:             0.1.6.1+-- The package version. See the Haskell package versioning policy (PVP)+-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary:      +-+------- breaking API changes+--                   | | +----- minor or non-breaking API additions+--                   | | | +--- code changes with no API change+version:             0.2.0.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).@@ -21,10 +24,9 @@ license-file:        LICENSE author:              Eric Kow maintainer:          Mikolaj Konarski <mikolaj.konarski@funktory.com>--- copyright: category:            Natural Language Processing build-type:          Simple-cabal-version:       >=1.8+cabal-version:       >=1.10  source-repository head   type:               git@@ -32,12 +34,23 @@  library   exposed-modules:     NLP.Minimorph.English-                       NLP.Minimorph.Number                        NLP.Minimorph.Util-  -- other-modules:+   build-depends:       base < 5                ,       text +  default-language:   Haskell2010+  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+  ghc-options:        -Wall-missed-specialisations+  ghc-options:        -fno-ignore-asserts -fexpose-all-unfoldings -fspecialise-aggressively+  }+ test-suite test-minimorph   type:       exitcode-stdio-1.0   main-is:    test-minimorph.hs@@ -49,3 +62,14 @@                ,       test-framework                ,       test-framework-hunit                ,       text+  default-language:   Haskell2010+  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+  ghc-options:        -Wall-missed-specialisations+  ghc-options:        -fno-ignore-asserts -fexpose-all-unfoldings -fspecialise-aggressively+  }
test/NLP/Minimorph/EnglishTest.hs view
@@ -2,12 +2,12 @@  module NLP.Minimorph.EnglishTest where -import Data.Text ( Text )+import           Data.Text (Text) import qualified Data.Text as T -import Test.HUnit-import Test.Framework.Providers.HUnit import Test.Framework+import Test.Framework.Providers.HUnit+import Test.HUnit  import NLP.Minimorph.English @@ -29,11 +29,10 @@ t_defaultVerbStuff =     testGroup "defaultVerbStuff" (map tc verbs)   where-    tc v@(pl, sg3, pastP) = testCase summary $+    tc (pl, sg3, pastP) = testCase summary $         assertEqual summary (sg3, pastP) (defaultVerbStuff pl)       where         summary = T.unpack $ T.concat [ pl, " (", sg3, ", ", pastP, ")" ]-        v2    = defaultVerbStuff pl  t_defaultNounPlural :: Test.Framework.Test t_defaultNounPlural =
test/test-minimorph.hs view
@@ -1,10 +1,8 @@-import Test.HUnit-import Test.Framework.Providers.HUnit import Test.Framework  import qualified NLP.Minimorph.EnglishTest  main :: IO ()-main = defaultMain +main = defaultMain         [ NLP.Minimorph.EnglishTest.suite         ]