alex.components.nlg.tectotpl.block.t2a.cs package

Submodules

alex.components.nlg.tectotpl.block.t2a.cs.addappositionpunct module

class alex.components.nlg.tectotpl.block.t2a.cs.addappositionpunct.AddAppositionPunct(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Separating Czech appositions, such as in ‘John, my best friend, ...’ with commas.

Arguments:
language: the language of the target tree selector: the selector of the target tree
add_comma_node(aparent)[source]

Add a comma a-node to the given parent

is_before_punct(anode)[source]

Test whether the subtree of the given node precedes a punctuation node.

process_tnode(tnode)[source]

Adds punctuation a-nodes if the given node is an apposition node.

alex.components.nlg.tectotpl.block.t2a.cs.addauxverbcompoundfuture module

class alex.components.nlg.tectotpl.block.t2a.cs.addauxverbcompoundfuture.AddAuxVerbCompoundFuture(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Add compound future auxiliary ‘bude’.

Arguments:
language: the language of the target tree selector: the selector of the target tree
process_tnode(tnode)[source]

Add compound future auxiliary to a node, where appropriate.

alex.components.nlg.tectotpl.block.t2a.cs.addauxverbcompoundpassive module

class alex.components.nlg.tectotpl.block.t2a.cs.addauxverbcompoundpassive.AddAuxVerbCompoundPassive(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Add compound passive auxiliary ‘být’.

Arguments:
language: the language of the target tree selector: the selector of the target tree
process_tnode(tnode)[source]

Add compound passive auxiliary to a node, where appropriate.

alex.components.nlg.tectotpl.block.t2a.cs.addauxverbcompoundpast module

class alex.components.nlg.tectotpl.block.t2a.cs.addauxverbcompoundpast.AddAuxVerbCompoundPast(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Add compound past tense auxiliary of the 1st and 2nd person ‘jsem/jsi/jsme/jste’.

Arguments:
language: the language of the target tree selector: the selector of the target tree
AUX_PAST_FORMS = {(u'P', u'2'): u'jste', (u'S', u'1'): u'jsem', (u'S', u'2'): u'jsi', (u'.', u'2'): u'jsi', (u'P', u'1'): u'jsme', (u'.', u'1'): u'jsem'}
process_tnode(tnode)[source]

Add compound past auxiliary to a node, where appropriate.

alex.components.nlg.tectotpl.block.t2a.cs.addauxverbconditional module

class alex.components.nlg.tectotpl.block.t2a.cs.addauxverbconditional.AddAuxVerbConditional(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Add conditional auxiliary ‘by’/’bych’.

Arguments:
language: the language of the target tree selector: the selector of the target tree
process_tnode(tnode)[source]

Add conditional auxiliary to a node, where appropriate.

alex.components.nlg.tectotpl.block.t2a.cs.addauxverbmodal module

class alex.components.nlg.tectotpl.block.t2a.cs.addauxverbmodal.AddAuxVerbModal(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Add modal verbs.

Arguments:
language: the language of the target tree selector: the selector of the target tree
DEONTMOD_2_MODAL = {u'vol': u'cht\xedt', u'hrt': u'm\xedt', u'perm': u'moci', u'fac': u'moci', u'deb': u'muset', u'poss': u'moci'}
process_tnode(tnode)[source]

Add modal auxiliary to a node, where appropriate.

alex.components.nlg.tectotpl.block.t2a.cs.addclausalexpletives module

class alex.components.nlg.tectotpl.block.t2a.cs.addclausalexpletives.AddClausalExpletives(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.addauxwords.AddAuxWords

Add clausal expletive pronoun ‘to’ (+preposition) to subordinate clauses with ‘že’, if the parent verb requires it.

Arguments:
language: the language of the target tree selector: the selector of the target tree
get_anode(tnode)[source]

Return the a-node that is the root of the verbal a-subtree.

get_aux_forms(tnode)[source]

Return the clausal expletive to be added, if supposed to.

new_aux_node(anode, form)[source]

Create a node for the expletive/its preposition.

postprocess(tnode, anode, aux_anodes)[source]

Rehang the conjunction ‘že’, now above the expletive, under it. Fix clause numbers and ordering.

alex.components.nlg.tectotpl.block.t2a.cs.addclausalpunct module

class alex.components.nlg.tectotpl.block.t2a.cs.addclausalpunct.AddClausalPunct(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

An abstract ancestor for blocks working with clausal punctuation.

Arguments:
language: the language of the target tree selector: the selector of the target tree
is_clause_in_quotes(anode)[source]

Return True if the given node is in an enquoted clause. The node must end the clause.

alex.components.nlg.tectotpl.block.t2a.cs.addcoordpunct module

class alex.components.nlg.tectotpl.block.t2a.cs.addcoordpunct.AddCoordPunct(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Add comma to coordinated lists of 3 and more elements, as well as before some Czech coordination conjunctions (‘ale’, ‘ani’).

Arguments:
language: the language of the target tree selector: the selector of the target tree
add_comma_node(anode)[source]

Add a comma AuxX node under the given node.

is_at_clause_boundary(anode)[source]

Return true if the given node is at a clause boundary (i.e. the nodes immediately before and after it belong to different clauses).

process_anode(anode)[source]

Add coordination punctuation to the given anode, if applicable.

alex.components.nlg.tectotpl.block.t2a.cs.addparentheses module

class alex.components.nlg.tectotpl.block.t2a.cs.addparentheses.AddParentheses(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Add ‘(‘ / ‘)’ nodes to nodes which have the wild/is_parenthesis attribute set.

Arguments:
language: the language of the target tree selector: the selector of the target tree
add_parenthesis_node(anode, lemma, clause_num)[source]

Add a parenthesis node as a child of the specified a-node; with the given lemma and clause number set.

continued_paren_left(anode)[source]

Return True if this node is continuing a parenthesis from the left.

continued_paren_right(anode)[source]

Return True if a parenthesis continues after this node to the right.

process_anode(anode)[source]

Add parentheses to an a-node, where appropriate.

alex.components.nlg.tectotpl.block.t2a.cs.addprepositions module

class alex.components.nlg.tectotpl.block.t2a.cs.addprepositions.AddPrepositions(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.addauxwords.AddAuxWords

Add prepositional a-nodes according to formemes.

Arguments:
language: the language of the target tree selector: the selector of the target tree
get_aux_forms(tnode)[source]

Find prepositional nodes to be created.

new_aux_node(anode, form)[source]

Create a prepositional node with the given preposition form and parent.

postprocess(tnode, anode, aux_nodes)[source]

Move rhematizers in front of the newly created PPs.

alex.components.nlg.tectotpl.block.t2a.cs.addreflexiveparticles module

class alex.components.nlg.tectotpl.block.t2a.cs.addreflexiveparticles.AddReflexiveParticles(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Add reflexive particles to reflexiva tantum and reflexive passive verbs.

Arguments:
language: the language of the target tree selector: the selector of the target tree
process_tnode(tnode)[source]

Add reflexive particle to a node, if applicable.

alex.components.nlg.tectotpl.block.t2a.cs.addsentfinalpunct module

class alex.components.nlg.tectotpl.block.t2a.cs.addsentfinalpunct.AddSentFinalPunct(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.cs.addclausalpunct.AddClausalPunct

Add final sentence punctuation (‘?’, ‘.’).

Arguments:
language: the language of the target tree selector: the selector of the target tree
process_ttree(troot)[source]

Add final punctuation to the given sentence.

alex.components.nlg.tectotpl.block.t2a.cs.addsubconjs module

class alex.components.nlg.tectotpl.block.t2a.cs.addsubconjs.AddSubconjs(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.addauxwords.AddAuxWords

Add subordinate conjunction a-nodes according to formemes.

Arguments:
language: the language of the target tree selector: the selector of the target tree
get_aux_forms(tnode)[source]

Find prepositional nodes to be created.

new_aux_node(anode, form)[source]

Create a subordinate conjunction node with the given conjunction form and parent.

alex.components.nlg.tectotpl.block.t2a.cs.addsubordclausepunct module

class alex.components.nlg.tectotpl.block.t2a.cs.addsubordclausepunct.AddSubordClausePunct(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.cs.addclausalpunct.AddClausalPunct

Add commas separating subordinate clauses.

Arguments:
language: the language of the target tree selector: the selector of the target tree
are_in_coord_clauses(aleft, aright)[source]

Check if the given nodes are in two coordinated clauses.

get_clause_parent(anode)[source]

Return the parent of the clause the given node belongs to; the result may be the root of the tree.

insert_comma_between(aleft, aright)[source]

Insert a comma node between these two nodes, find out where to hang it.

process_atree(aroot)[source]

Add subordinate clause punctuation to the given sentence.

alex.components.nlg.tectotpl.block.t2a.cs.capitalizesentstart module

class alex.components.nlg.tectotpl.block.t2a.cs.capitalizesentstart.CapitalizeSentStart(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Capitalize the first word in the sentence (skip punctuation etc.).

OPEN_PUNCT = u'^[({[\u201a\u201e\xab\u2039|*"\\\']+$'
process_zone(zone)[source]

Find the first valid word in the sentence and capitalize it.

alex.components.nlg.tectotpl.block.t2a.cs.deletesuperfluousauxs module

class alex.components.nlg.tectotpl.block.t2a.cs.deletesuperfluousauxs.DeleteSuperfluousAuxs(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Delete repeated prepositions and and conjunctions in coordinations.

BASE_DIST_LIMIT = 8
DIST_LIMIT = {u'mezi': 50, u'pro': 8, u'proto\u017ee': 5, u'v': 5}
process_tnode(tnode)[source]

Check for repeated prepositions and and conjunctions in coordinations, delete them if necessary.

alex.components.nlg.tectotpl.block.t2a.cs.dropsubjpersprons module

class alex.components.nlg.tectotpl.block.t2a.cs.dropsubjpersprons.DropSubjPersProns(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Remove the Czech pro-drop subject personal pronouns (or demonstrative “to”) from the a-tree.

Arguments:
language: the language of the target tree selector: the selector of the target tree
drop_anode(tnode)[source]

Remove the lexical a-node corresponding to the given t-node

process_tnode(tnode)[source]

Check if the a-node corresponding to the given t-node should be dropped, and do so where appropriate.

alex.components.nlg.tectotpl.block.t2a.cs.generatepossessiveadjectives module

class alex.components.nlg.tectotpl.block.t2a.cs.generatepossessiveadjectives.GeneratePossessiveAdjectives(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

According to formemes, this changes the lemma of the surface possessive adjectives from the original (deep) lemma which was identical to the noun from which the adjective is derived, e.g. changes the a-node lemma from ‘Čapek’ to ‘Čapkův’ if the corresponding t-node has the ‘adj:poss’ formeme.

Arguments:
language: the language of the target tree selector: the selector of the target tree
load()[source]
process_tnode(tnode)[source]

Check a t-node if its lexical a-node should be changed; if yes, update its lemma.

alex.components.nlg.tectotpl.block.t2a.cs.generatewordforms module

alex.components.nlg.tectotpl.block.t2a.cs.imposeattragr module

class alex.components.nlg.tectotpl.block.t2a.cs.imposeattragr.ImposeAttrAgr(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.imposeagreement.ImposeAgreement

Impose case, gender and number agreement of attributes with their governing nouns.

Arguments:
language: the language of the target tree selector: the selector of the target tree
impose(tnode, match_nodes)[source]

Impose case, gender and number agreement on attributes.

process_excepts(tnode, match_nodes)[source]

Handle special cases for this rule: nic/něco, numerals.

should_agree(tnode)[source]

Find adjectives with a noun parent. Returns the a-layer nodes for the adjective and its parent, or False

alex.components.nlg.tectotpl.block.t2a.cs.imposecomplagr module

class alex.components.nlg.tectotpl.block.t2a.cs.imposecomplagr.ImposeComplAgr(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.imposeagreement.ImposeAgreement

Impose agreement of adjectival verb complements with the subject.

Arguments:
language: the language of the target tree selector: the selector of the target tree
impose(tnode, match_nodes)[source]

Impose the agreement on selected adjectival complements.

process_excepts(tnode, match_nodes)[source]

Returns False; there are no special cases for this rule.

should_agree(tnode)[source]

Find the complement and its subject.

alex.components.nlg.tectotpl.block.t2a.cs.imposepronzagr module

class alex.components.nlg.tectotpl.block.t2a.cs.imposepronzagr.ImposePronZAgr(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.imposeagreement.ImposeAgreement

In phrases such as ‘každý z ...’,’žádná z ...’, impose agreement in gender.

Arguments:
language: the language of the target tree selector: the selector of the target tree
PRONOUNS = u'^(jeden|ka\u017ed\xfd|\u017e\xe1dn\xfd|oba|v\u0161echen|(n\u011b|lec)kter\xfd|(jak|kter)\xfdkoliv?|libovoln\xfd)$'
impose(tnode, tchild)[source]

Impose the gender agreement on selected nodes.

process_excepts(tnode, match_nodes)[source]

Returns False; there are no special cases for this rule.

should_agree(tnode)[source]

Find matching pronouns with ‘z+2’-formeme children.

alex.components.nlg.tectotpl.block.t2a.cs.imposerelpronagr module

class alex.components.nlg.tectotpl.block.t2a.cs.imposerelpronagr.ImposeRelPronAgr(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.imposeagreement.ImposeAgreement

Impose gender and number agreement of relative pronouns with their antecedent.

Arguments:
language: the language of the target tree selector: the selector of the target tree
impose(tnode, tantec)[source]

Impose the gender agreement on selected nodes.

process_excepts(tnode, match_nodes)[source]

Returns False; there are no special cases for this rule.

should_agree(tnode)[source]

Find relative pronouns with a valid antecedent.

alex.components.nlg.tectotpl.block.t2a.cs.imposesubjpredagr module

class alex.components.nlg.tectotpl.block.t2a.cs.imposesubjpredagr.ImposeSubjPredAgr(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.block.t2a.imposeagreement.ImposeAgreement

Impose gender and number agreement of relative pronouns with their antecedent.

Arguments:
language: the language of the target tree selector: the selector of the target tree
impose(tnode, match_nodes)[source]

Impose the subject-predicate agreement on regular nodes.

process_excepts(tnode, match_nodes)[source]

Returns False; there are no special cases for this rule.

should_agree(tnode)[source]

Find finite verbs, with/without a subject.

alex.components.nlg.tectotpl.block.t2a.cs.initmorphcat module

class alex.components.nlg.tectotpl.block.t2a.cs.initmorphcat.InitMorphcat(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

According to t-layer grammatemes, this initializes the morphcat structure at the a-layer that is the basis for a later POS tag limiting in the word form generation.

Arguments:
language: the language of the target tree selector: the selector of the target tree
DEGREE = {u'comp': u'2', u'pos': u'1', u'acomp': u'2', u'sup': u'3', None: u'.', u'nr': u'.'}
GENDER = {u'anim': u'M', u'fem': u'F', u'inan': u'I', u'inher': u'.', u'neut': u'N', None: u'.', u'nr': u'.'}
NEGATION = {None: u'A', u'neg0': u'A', u'neg1': u'N'}
NUMBER = {None: u'.', u'nr': u'.', u'sg': u'S', u'pl': u'P', u'inher': u'.'}
PERSON = {u'1': u'1', None: u'.', u'3': u'3', u'2': u'2', u'inher': u'.'}
VOICE = {u'pas': u'P', u'deagent': u'A', u'passive': u'P', u'act': u'A', u'active': u'A', None: u'.'}
process_tnode(tnode)[source]

Initialize the morphcat structure in the given node

set_case(tnode, anode)[source]

Set the morphological case for an a-node according to the corresponding t-node’s formeme, where applicable.

set_perspron_categories(tnode, anode)[source]

Set detailed morphological categories of personal pronouns of various types (possessive, reflexive, personal per se)

alex.components.nlg.tectotpl.block.t2a.cs.marksubject module

class alex.components.nlg.tectotpl.block.t2a.cs.marksubject.MarkSubject(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Marks the subject of each clause with the Afun ‘Sb’.

Arguments:
language: the language of the target tree selector: the selector of the target tree
process_ttree(ttree)[source]

Mark all subjects in a sentence

alex.components.nlg.tectotpl.block.t2a.cs.markverbalcategories module

class alex.components.nlg.tectotpl.block.t2a.cs.markverbalcategories.MarkVerbalCategories(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Finishes marking synthetic verbal categories: tense, finiteness, mood.

Arguments:
language: the language of the target tree selector: the selector of the target tree
mark_subpos_tense(tnode, anode)[source]

Marks the Sub-POS and tense parts of the morphcat structure in plain verbal a-nodes.

process_tnode(tnode)[source]

Marks verbal categories for a t-node.

resolve_imperative(anode)[source]

Mark an imperative a-node.

resolve_infinitive(anode)[source]

Mark an infinitive a-node correctly.

alex.components.nlg.tectotpl.block.t2a.cs.movecliticstowackernagel module

class alex.components.nlg.tectotpl.block.t2a.cs.movecliticstowackernagel.MoveCliticsToWackernagel(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Move clitics (e.g. ‘se’, ‘to’ etc.) to the second (Wackernagel) position in the clause.

clitic_order(clitic)[source]

Return the position of the given clitic in the natural Czech order of multiple clitics in the same clause.

find_eo1st_pos(clause_root, clause_1st)[source]

Find the last word before the Wackernagel position.

handle_pronoun_je(anode)[source]

If the given node is a personal pronoun with the form ‘je’, move it before its parent’s subtree and return True. Return false otherwise.

is_clitic(anode)[source]

Return True if the given node belongs to a clitic.

is_coord_taking_1st_pos(clause_root)[source]

Return True if the clause root is a coordination member and the coordinating conjunction or shared subjunction is taking up the 1st position. E.g. ‘Běžel, aby se zahřál a dostal se dřív domů.’

process_atree(aroot)[source]

Process the individual clauses – find and move clitics within them.

process_clause(clause)[source]

Find and move clitics within one clause.

should_ignore(anode, clause_number)[source]

Return True if this word should be ignored in establishing the Wackernagel position.

verb_group_root(clitic)[source]

Find the root of the verbal group that the given clitic belongs to. If the verbal group is governed by a conjunction, return this conjunction.

alex.components.nlg.tectotpl.block.t2a.cs.projectclausenumber module

class alex.components.nlg.tectotpl.block.t2a.cs.projectclausenumber.ProjectClauseNumber(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

Project clause numbering from t-nodes to a-nodes.

Arguments:
language: the language of the target tree selector: the selector of the target tree
process_tnode(tnode)[source]

Project the t-node’s clause number to all its corresponding a-nodes.

alex.components.nlg.tectotpl.block.t2a.cs.reversenumbernoundependency module

class alex.components.nlg.tectotpl.block.t2a.cs.reversenumbernoundependency.ReverseNumberNounDependency(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

This block reverses the dependency of incongruent Czech numerals (5 and higher), hanging their parents under them in the a-tree.

Arguments:
language: the language of the target tree selector: the selector of the target tree
process_ttree(ttree)[source]

Rehang the numerals for the given t-tree & a-tree pair

alex.components.nlg.tectotpl.block.t2a.cs.vocalizeprepos module

class alex.components.nlg.tectotpl.block.t2a.cs.vocalizeprepos.VocalizePrepos(scenario, args)[source]

Bases: alex.components.nlg.tectotpl.core.block.Block

This block replaces the forms of prepositions ‘k’, ‘v’, ‘z’, ‘s’ with their vocalized variants ‘ke’/’ku’, ‘ve’, ‘ze’, ‘se’ according to the following word.

process_atree(aroot)[source]

Find and vocalize prepositions according to their context.

vocalize(prep, follow)[source]

Given a preposition lemma and the form of the word following it, return the appropriate form (base or vocalized).

Module contents