Tool in Mylly: Relation algebra / Composition | fi
Composition of relations
Composition takes two relations and produces the set of combinations of the non-shared attributes where the shared attributes match. Use composition instead of join only when the shared attributes are not of interest in the result.
The input and output relations are represented as TSV files.
Example
The first input relation consists of some word forms annotated with a lemma, a sentence number, and a token number. The second input relation consists of sentence numbers annotated with the mood of a sentence.
sen | tok | lemma | word |
---|---|---|---|
3 | 3 | niin | niin |
3 | 2 | se | se |
3 | 1 | olla | on |
5 | 1 | olla | on |
sen | mood |
---|---|
3 | calm |
4 | calm |
5 | angry |
The output relation consists of those word forms in the first input relation that had their sentence number in the second input relation (all of them), still annotated with their token numbers and lemmas, no longer with the sentence number, but now also with the mood of the sentence.
tok | mood | lemma | word |
---|---|---|---|
3 | calm | niin | niin |
2 | calm | se | se |
1 | calm | olla | on |
1 | angry | olla | on |
Note that the two occurrences of on in the result are separate records only because their sentences were annotated with different moods.
Related tools
See also
- Relation algebra for context