Safe Haskell | None |
---|---|
Language | Haskell2010 |
This is a very simple wrapper around Parsec for writing Information Extraction patterns.
Because the particular tags/tokens to parse depends on the training corpus (for POS tagging) and the domain, this module only provides basic extractors. You can, for example, create an extractor to find noun phrases by combining the components provided here:
nounPhrase :: Extractor (Text, Tag) nounPhrase = do nlist <- many1 (try (posTok $ Tag "NN") <|> try (posTok $ Tag "DT") <|> (posTok $ Tag "JJ")) let term = T.intercalate " " (map fst nlist) return (term, Tag "n-phr")
- type Extractor = Parsec TaggedSentence ()
- posTok :: Tag -> Extractor (Text, Tag)
- posPrefix :: Text -> Extractor (Text, Tag)
- matches :: CaseSensitive -> Text -> Text -> Bool
- txtTok :: CaseSensitive -> Text -> Extractor (Text, Tag)
- anyToken :: Extractor (Text, Tag)
- oneOf :: CaseSensitive -> [Text] -> Extractor (Text, Tag)
- followedBy :: Extractor b -> Extractor a -> Extractor a
Documentation
type Extractor = Parsec TaggedSentence () Source
A Parsec parser.
Example usage:
> set -XOverloadedStrings > import Text.Parsec.Prim > parse myExtractor "interactive repl" someTaggedSentence
matches :: CaseSensitive -> Text -> Text -> Bool Source
Text equality matching with optional case sensitivity.
txtTok :: CaseSensitive -> Text -> Extractor (Text, Tag) Source
Consume a token with the given lexical representation.
oneOf :: CaseSensitive -> [Text] -> Extractor (Text, Tag) Source
followedBy :: Extractor b -> Extractor a -> Extractor a Source
Skips any number of fill tokens, ending with the end parser, and returning the last parsed result.
This is useful when you know what you're looking for and (for instance) don't care what comes first.