LingDepend

LingDepend.xsl — Uses a syntactic dictionary to inflect dependent words, e.g. determiners, adjectives, and relative pronouns, in an XML document.

Parameters

[Verbose]
  • Verbose (Boolean) — Whether full error messages should be displayed.

Input

An XML document. You must mark up the source document with linguistic attributes identifying the dependent words in the document and describing the syntactic and / or phonetic environment for each dependent word.

Output

An XML document, identical to the input except that dependent words are inflected by phonology, case, gender and number, as required by the current language.

Description

The stylesheet recurses through the document and copies each element. If any element has the attribute ling:type='depend', the stylesheet looks for the correct syntactic dictionary for the current language, as specified by the nearest ancestor xml:lang attribute.

The stylesheet uses the text content of the dependent word to look up the correct word in the syntactic dictionary and find all its possible inflected forms. It then determines the syntactic and / or phonetic environment for the dependent word, according to the following algorithm:

  1. If the dependent word has phonologically-conditioned variants, the stylesheet looks for the nearest following sibling element which has a ling:pron attribute, or which has a child element with a ling:pron attribute.

  2. If the dependent word has number, case, gender or (in)definite variants, the stylesheet looks in turn for the nearest element in the document tree with a ling:num, ling:case, ling:gen or ling:class attribute, as the current language requires.

Having determined the syntactic and / or phonetic environment, the stylesheet copies the correct inflected form of the dependent word into the document.

This is useful for transclusion. If you transclude a term into a document, you can inflect dependent words such as determiners, adjectives, and relative pronouns which surround the transcluded term.

The syntactic dictionaries for the supported languages are stored in the tei subdirectory.

If the Verbose parameter is set to true, i.e. anything other than 0 or the empty string, detailed messages are displayed as each dependent word is inflected. This can help to work out what’s gone wrong when a word is not inflected properly.

Capitalisation

If the text in this element begins with a capital letter, the stylesheet adds a ling:orth='sentence' attribute to the element. You can then pass the output document to the LingCasing.xsl stylesheet to capitalise the first letter of the returned word. Otherwise, the word is returned in lower case.

Roadmap

In DocBook files, this stylesheet matches wordasword elements as well as elements with the ling:type='depend' attribute. This may be removed in a future release.