Tool in Mylly: Relation algebra / Keep with count | fi
Keep/count selected attributes
The ”keep with count” operation projects an input relation to the selected attributes with the addition of a new count attribute to record the multiplicity in the input relation of the kept combinations.
The input and output relations are represented as TSV files.
Parameters
- name for the count attribute
- zero or more attributes
Attributes are presented as menus that list the attributes that the relation has. EMPTY indicates that the parameter is not used.
Selecting the same attribute more than once is harmless.
(Selecting no attributes, by leaving every attribute parameter at EMPTY, produces a relation with no attributes. There are two such relations.)
Example
The input relation consists of word forms annotated with sentence and token numbers and lemmas.
word | tok | sen | lemma |
---|---|---|---|
on | 1 | 3 | olla |
se | 2 | 3 | se |
niin | 3 | 3 | niin |
on | 1 | 5 | olla |
ei | 1 | 4 | ei |
ole | 2 | 4 | olla |
The count attribute is named count. (The default name is cMcount.)
When the word form and lemma are kept, the two occurrences of olla as on melt into one record.
count | lemma | word |
---|---|---|
1 | ei | ei |
1 | se | se |
1 | niin | niin |
2 | olla | on |
1 | olla | ole |
When only the lemma is kept, all three occurrences of olla melt into one record.
lemma | |
---|---|
1 | ei |
1 | se |
3 | olla |
1 | niin |
Related tools
- drop with count
- keep