HsHyperEstraier-0.4: HyperEstraier binding for Haskell

Text.HyperEstraier.Document

Contents

Description

An interface to manipulate documents of the HyperEstraier.

Synopsis

Types

data Document

Document is an opaque object representing a document of HyperEstraier.

type DocumentID = Int

DocumentID is just an alias to Int. It represents a document ID.

Creating and parsing document

newDocument :: IO Document

newDocument creates an empty document.

parseDraft :: Text -> IO Document

parseDraft parses a document in the "draft" format.

Setting contents and attributes of document

addText :: Document -> Text -> IO ()

Add a block of text to a document.

addHiddenText :: Document -> Text -> IO ()

Add a block of hidden text to a document.

setAttribute

Arguments

:: Document

The document.

-> Text

An attribute name.

-> Maybe Text

An attribute value. If this is Nothing, the attribute will be deleted.

-> 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.

setKeywords

Arguments

:: Document

The document.

-> [(Text, Integer)]

A list of (keyword, score).

-> IO () 

Set keywords of a document.

setScore :: Document -> Maybe Int -> IO ()

Set an alternative score 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.

getText :: Document -> IO Text

Get the text in a document.

getURI :: Document -> IO (Maybe URI)

Get the URI of a document.

getKeywords :: Document -> IO [(Text, Integer)]

Get the keywords of a document.

getScore :: Document -> IO (Maybe Int)

Get an alternative score of a document.

Dumping document

dumpDraft :: Document -> IO Text

Dump a document in the "draft" format.

Making snippet of document

makeSnippet

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 (Left non-highlighted text) or (Right (highlighted word, its normalized form)).

Make a snippet from a document.