Exploring multilingual resources for cross-lingual Natural Language Processing

Daniel Zeman (zeman@ufal.mff.cuni.cz)

Lecture slides

  1. Introduction to dependency grammar and treebanks
  2. Universal Dependencies: words and morphology
  3. Universal Dependencies: syntax
  4. Enhanced Universal Dependencies

Practicals

Some useful links:

Searching UD treebanks in Grew Match

The general Grew Match homepage is https://match.grew.fr/. An online tutorial is accessible from here.

For UD and SUD, click on https://universal.grew.fr/. Then in the blue top line menu, you can choose between UD and SUD releases. Choose “UD 2.18”. (“UD latest” refers to the unreleased changes that are being prepared on GitHub, and this choice is available only for a few treebanks.)

Select treebank in the gray column on the left. You can select multiple treebanks (up to 15 at once) if you first click on the three dots in the first line.

  • A few treebanks lack underlying texts for license reasons. Avoid them. (Watch for the missing words icon icon.)
  • Some treebanks include so-called enhanced dependency representation (the enhanced dependency representation icon). Such treebanks also have a bUD (basic universal dependencies) version available (you should see it on the next line, with the gear icon). We will not work with the enhanced dependencies at this moment, so choose the bUD version when available.

For a better list of UD languages go to https://universaldependencies.org/languages.html. You can e.g. filter the list to see all Romance languages and their UD treebanks.

Some notes and patterns to try:

pattern { N [form="to"] }

… inspect annotation of to in English. Many occurrences (over 1000, the search limit). Note that instead of “Search”, you can press “Count” and you will get the total number of occurrences in the corpus.

Also note that the “N” in the pattern is just a name we gave the node for the purpose of this search. Grew Match can use that label to show us the node in the example sentences it finds (unless we turn off displaying of node names), and we may need the name to refer back to this node elsewhere in the query or in the “clustering” function. But it does not matter we chose “N”. We could call it “X”, “A1”, or even “John”. It is not something encoded in the treebank. It only has to be a unique name within our current query.

We see that its UPOS can be ADP. Can it be also something else?

pattern { N [form="to", upos<>ADP] }

it can be also PART. What else?

pattern { N [form="to", upos<>ADP|PART] }

Instead of gradually filtering UPOS tags you have seen in the examples, you can remove the upos constraint and instead ask that the results be clustered by Key N.uposSee “Clustering 1” in the search form. Remember, if you then press Search, you may still see clusters over only part of the corpus (first 1000 results). If you click on Count, you will get numbers from the whole corpus. However, Search has another advantage: You can click on numbers of individual clusters and see the example results with their annotation.

pattern { N -[amod]-> M }

Now we can cluster by upos categories of both nodes and we get a two-dimensional table.

pattern { N -[amod]-> M } without { N [upos=NOUN]; M [upos=ADJ] }

Look at dependencies (edges) where the child node is an adjective.

pattern { M -> N; N [upos=ADJ] }

We can cluster it by M.upos (for example). If we want clustering by dependency types, we have to name the relation (edge) first. Then we get the deprel as the edge’s attribute “label” (e.label).

pattern { e: M -> N; N [upos=ADJ] }

We can examine correlation between M.upos and e.label: besides “Clustering 1”, invoke also “Clustering 2”!

If a pattern contains 2 nodes without additional conditions and relations, the results will be sentences where both the nodes are present. For example,

pattern { N1 [form="to"]; N2 [form="sleep"] }

will find sentences containing to a sleep, but it does not have to be the infinitive “to sleep”. The two words can be also in reversed order and far apart. If you want words that follow each other, add the “<” operator (word order, adjacent words; if you only want word order but not adjacency, use “<<” instead):

pattern { N1 [lemma="in"]; N2 [lemma="front"]; N1 < N2; N3 [lemma="of"]; N2 < N3 }

pattern { V -[nsubj]-> S; V << S }

examine word order. Look for nominal subjects that follow their verbs. We could do the same for the other direction and also for verb vs. object. But instead we can also use clustering, this time with the “Whether” option (put V << S into the Whether field). Similarly,

pattern { V -[obj]-> O }

and clustering whether V << O.

Finally, we can combine all three nodes (verb, subject and object) in one pattern:

pattern { V -[nsubj]-> S; V -[obj]-> O }

and use a Key-type pattern with a special key

S#V#O

(or O#V#S or other orders, important is the operator).

Precomputed table of relations

Note the  icon in the upper line next to the treebank name. It has one option called “Relations tables”. It gives you a separate page with precomputed double clustering of parent.upos and child.upos for each relation type found in the treebank.

Exercises

  1. The AUX UPOS tag denotes auxiliary verbs (or words that have an auxiliary function although they do not look like verbs). Pick a language/treebank and list the lemmas of all auxiliaries used in the treebank, along with their counts.

  2. Try the same search in a related language and compare. For example, you can compare the list of verbs treated as auxiliaries in the Portuguese treebanks with Galician and Spanish.

  3. List the labels of dependency relations where the child node is an AUX.

  4. More generally, look for correlation between dependency relations and child UPOS tags in the treebank (two-dimensional clustering). Note: The web interface will truncate the table if there are more than 10 rows or columns. But you can download the full table as TSV (tab-separated-values) and then open it in an office spreadsheet program.

  5. It is not uncommon that the same word can be used as auxiliary (AUX) and as main verb (VERB). Figure out whether there are such lemmas in your treebank. Is there a lemma that is used more often as VERB than as AUX? Does any of the AUX lemmas occur also with other UPOS categories?

  6. In an English treebank, survey the UPOS of the lemma have and the dependency relations with its parent.

  7. Pick a morphologically rich language with a large treebank (so you have the chance of observe many forms of a lexeme). Identify the VERB or AUX lemma with the most occurrences. How many different forms can this lemma have? Can you find more than 100 clusters? (Note: Doing this for the verb with the most occurrences does not guarantee that this is the verb with the most forms. So you can try others if you want.)

  8. Find adjectives modifying nouns via the relation “amod”. Are there features like Gender, Number, Case, in which the two words typically agree? For example, can we confirm from the data that English adjectives do not agree with the nouns they modify, while Czech adjectives do?

  9. Find verbs and their direct objects (relation “obj”). Depending on which language you are playing with, there might be different clues that make the object recognizable. Is it always before/after the verb. Immediately before/after, or can there be something in between? Is the object marked morphologically (examine the value of its Case feature)? Or does it have an adposition (ADP) child? Are there differences between objects that are NOUN, PROPN (proper noun) or personal pronoun (PRON, with the feature PronType=Prs)? You can try the same set of tests with nominal subjects (“nsubj”), indirect objects (“iobj”), or, in some languages, with “obl:arg”.

  10. Find fixed expressions (relation “fixed”) consisting of 3 words.

  11. Find occurrences of a concrete n-gram (n words in a sequence).

More stuff

% Regular expression can be used for filtering (“.*” stands for “any number of any characters”).

pattern { X [ form = re".*ing" ] }

% Require a feature to be there (any non-empty value).

pattern { X [ upos=VERB, Tense ] }

% Require a feature not to be there.

pattern { X [ upos=VERB, !Mood ] }

% Search for a relation different from a given disjunction.

pattern { X -[^nsubj|obj]-> Y }

% Use regular expression to match a set of labels. Here, search for a relation whose name begins with “aux” (including subtypes such as “aux:pass”).

pattern { X -[re"aux.*"]-> Y }

% The request below searches for verbs without a nominal subject:

pattern { V [upos=VERB] } % ← declares a node “V” with the UPOS “VERB”

without { V -[nsubj|nsubj:pass]-> S } % ← filters out cases where there is a node “S” with a subject relation from “V” to “S”

% Search for the verb “make” without both subject AND object. Compare with the next example with 2 separate “without” clauses.

pattern { V [upos=VERB, lemma=make] }
without { V -[nsubj|nsubj:pass]-> S; V -[obj]-> O }

% Search for the verb “make” without either subject OR object. Compare with the previous example with only one “without” clause.

pattern { V [upos=VERB, lemma=make] }
without { V -[nsubj|nsubj:pass]-> S }
without { V -[obj]-> O }

Searching UD treebanks with Udapi (Python)

We will use Google Colab with this interactive Python notebook. You probably need a Google account to be able to use Colab. If you prefer running Python locally on your computer, it is possible but you will have to extract the Python code from the code cells in the notebook. We will work with one of several existing Python libraries for UD data, namely, Udapi.

  • Here is a version of the notebook as we modified it in the class 2026-07-22.