packages feed

chatter 0.5.0.0 → 0.5.0.1

raw patch · 5 files changed

+62/−26 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

chatter.cabal view
@@ -1,5 +1,5 @@ name:                chatter-version:             0.5.0.0+version:             0.5.0.1 synopsis:            A library of simple NLP algorithms. description:         chatter is a collection of simple Natural Language                      Processing algorithms.
src/NLP/Chunk.hs view
@@ -1,4 +1,31 @@ {-# LANGUAGE OverloadedStrings #-}+{-|+Module      : NLP.Chunk+Description : Phrase Chunking facilities.+Copyright   : Rogan Creswick, 2014+Maintainer  : creswick@gmail.com+Stability   : experimental++NLP.Chunk aims to make phrasal chunking trivially easy -- it is the+corolary to NLP.POS.++The simplest way to try out chunking with Chatter is to open a repl+after installing chatter and try this:++>> import NLP.POS+>> import NLP.Chunk+>> tgr <- defaultTagger+>> chk <- defaultChunker+>> chunkText tgr chk "Monads are monoids in the category of endofunctors."+> "[NP Monads/NNS are/VBP monoids/NNS] [PP in/IN] [NP the/DT category/NN] [PP of/IN] [NP endofunctors/NNS] ./."++Note that it isn't perfect--phrase chunking is tricky, and the+'defaultTagger' and 'defaultChunker' aren't trained on the largest+training set (they use Conll 2000).  You can easily train more taggers+and chunkers using the APIs exposed here if you have the training data+to do so.++-} module NLP.Chunk where 
src/NLP/Chunk/AvgPerceptronChunker.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-}+{--} -- | Avegeraged Perceptron Chunker -- module NLP.Chunk.AvgPerceptronChunker
src/NLP/Corpora/Email.hs view
@@ -6,8 +6,9 @@ import Data.List (isSuffixOf) import Data.Text (Text) import qualified Data.Text.Encoding as TE+import qualified Data.Text.Lazy as LT -import Data.MBox+import Data.MBox (body, Message, parseMBox)  import System.Directory (getDirectoryContents) import System.FilePath ((</>))@@ -21,12 +22,12 @@ plugArchiveText :: IO [Text] plugArchiveText = do   archive <- fullPlugArchive-  return $ map body archive+  return $ map (LT.toStrict . body) archive  plugArchiveTokens :: IO [[Text]] plugArchiveTokens = do   archive <- fullPlugArchive-  return $ map (tokenize . body) archive+  return $ map (tokenize . LT.toStrict . body) archive  fullPlugArchive :: IO [Message] fullPlugArchive = do@@ -35,7 +36,7 @@   contents <- mapM (\f->readF (plugDataPath </> f)) archiveFiles   return $ concatMap parseMBox contents -readF :: FilePath -> IO Text+readF :: FilePath -> IO LT.Text readF file = do   bs <- BS.readFile file-  return $ TE.decodeLatin1 bs+  return $ LT.fromStrict $ TE.decodeLatin1 bs
src/NLP/POS.hs view
@@ -1,24 +1,31 @@ {-# LANGUAGE OverloadedStrings #-}--- | This module aims to make tagging text with parts of speech--- trivially easy.------ If you're new to 'chatter' and POS-tagging, then I--- suggest you simply try:------ >>> tagger <- defaultTagger--- >>> tagStr tagger "This is a sample sentence."--- "This/dt is/bez a/at sample/nn sentence/nn ./."------ Note that we used 'tagStr', instead of 'tag', or 'tagText'.  Many--- people don't (yet!) use "Data.Text" by default, so there is a--- wrapper around 'tag' that packs and unpacks the 'String'.  This is--- innefficient, but it's just to get you started, and 'tagStr' can be--- very handy when you're debugging a tagger in ghci (or cabal repl).------ 'tag' exposes more details of the tokenization and tagging, since--- it returns a list of `TaggedSentence`s, but it doesn't print--- results as nicely.---+{-|+Module      : NLP.POS+Description : Part-of-Speech tagging facilities.+Copyright   : Rogan Creswick, 2014+Maintainer  : creswick@gmail.com+Stability   : experimental++This module aims to make tagging text with parts of speech+trivially easy.++If you're new to 'chatter' and POS-tagging, then I+suggest you simply try:++>>> tagger <- defaultTagger+>>> tagStr tagger "This is a sample sentence."+"This/dt is/bez a/at sample/nn sentence/nn ./."++Note that we used 'tagStr', instead of 'tag', or 'tagText'.  Many+people don't (yet!) use "Data.Text" by default, so there is a+wrapper around 'tag' that packs and unpacks the 'String'.  This is+innefficient, but it's just to get you started, and 'tagStr' can be+very handy when you're debugging a tagger in ghci (or cabal repl).++'tag' exposes more details of the tokenization and tagging, since+it returns a list of `TaggedSentence`s, but it doesn't print+results as nicely.+-} module NLP.POS   ( tag   , tagStr