antfarm- Referring expressions for definitions

Safe HaskellSafe-Infered




Referring expression generation for definitions.


Key structures

Discourse history

data RefHistory Source




rhCount :: Map DiscourseUnit RefCount

How many times a DiscourseUnit has been mentioned

rhOrder :: Map Text [Text]

For each class: an ordering of indices that reflects what ordinal expression should be used for them (if at all)

So [c8,c3,c4] means

c8: the first c3: the second c4: the third

addToHistory :: [DiscourseUnit] -> RefHistory -> RefHistorySource

Take note of the fact that these discourse units have been mentioned (again) in the history.

You probably want to realise the units first, then add them to the history.

emptyHistory :: RefHistorySource

Discourse history without any objects

noteImplicitBounds :: RefGroup -> RefGroupSource

If a RefGroup has explicit constraints, augment them with the implicit constraints that arise from treating each item as evidence of an at least constraint

It's a good idea to run this once when building RefGroups, but you may also decide that this sort of behaviour is not desirable for your application, so it's off by default

Core generation

rx :: RefHistory -> [Tree SubRxInput] -> [Tree SubRx]Source

Decide how to realise a referring expression

subrx :: RefHistory -> Tree SubRxInput -> Tree SubRxSource

Decide how to realise a single unit within a referring expression

Keep in mind that this is only for one DiscourseUnit within a single rx. An rx may involve multiple discourse units (eg. 3 cats and 1 dog)

subrxNumber :: DiscourseUnit -> FuzzyNumberSource

Whether a DiscourseUnit should be considered *morally* (semantically) singular or plural. The actual form used may be different (see conceptNumber because of deeper issues that override this).

Consider one of the *dogs*; here the rx number is Singular — one dog — but on the surface we use the Plural (the NP 'the dogs' is itself plural). This discrepency is partly due to the hacky way we've written this. A cleaner implementation would recursively realise 'the dogs' as a separate expression with its own number.

English surface form

englishRx :: [Tree SubRx] -> TextSource

English realisation for a referring expression

englishSubrx :: SubRx -> TextSource

English realisation for a referring expression subunit (this can be useful if you need special formatting between units, eg. bullet points)