Text.HyperEstraier.Document
Contents
Description
An interface to manipulate documents of the HyperEstraier.
- data Document
- type DocumentID = Int
- newDocument :: IO Document
- parseDraft :: Text -> IO Document
- addText :: Document -> Text -> IO ()
- addHiddenText :: Document -> Text -> IO ()
- setAttribute :: Document -> Text -> Maybe Text -> IO ()
- setURI :: Document -> Maybe URI -> IO ()
- setKeywords :: Document -> [(Text, Integer)] -> IO ()
- setScore :: Document -> Maybe Int -> IO ()
- getId :: Document -> IO DocumentID
- getAttrNames :: Document -> IO [Text]
- getAttribute :: Document -> Text -> IO (Maybe Text)
- getText :: Document -> IO Text
- getURI :: Document -> IO (Maybe URI)
- getKeywords :: Document -> IO [(Text, Integer)]
- getScore :: Document -> IO (Maybe Int)
- dumpDraft :: Document -> IO Text
- makeSnippet :: Document -> [Text] -> Int -> Int -> Int -> IO [Either Text (Text, Text)]
Types
type DocumentID = Int
DocumentID
is just an alias to Int
. It represents a
document ID.
Creating and parsing document
newDocument
creates an empty document.
parseDraft :: Text -> IO Document
parseDraft
parses a document in the "draft" format.
Setting contents and attributes of document
addHiddenText :: Document -> Text -> IO ()
Add a block of hidden text to a document.
Arguments
:: Document | The document. |
-> Text | An attribute name. |
-> Maybe Text | An attribute value. If this is
|
-> IO () |
Set an attribute value of a document.
setURI :: Document -> Maybe URI -> IO ()
Set an URI of a document. This is a special case of
setAttribute
.
Set keywords of a document.
Getting contents and attributes of document
getId :: Document -> IO DocumentID
Get the ID of document.
getAttrNames :: Document -> IO [Text]
Get a list of all attribute names in a document.
getAttribute :: Document -> Text -> IO (Maybe Text)
Get an attribute value of a document.
getKeywords :: Document -> IO [(Text, Integer)]
Get the keywords of a document.
Dumping document
Making snippet of document
Arguments
:: Document | The document. |
-> [Text] | Words to be highlighted. |
-> Int | Maximum width of the whole result. |
-> Int | Width of the heading text to be shown. |
-> Int | Width of the text surrounding each highlighted words. |
-> IO [Either Text (Text, Text)] | A list of either
|
Make a snippet from a document.