Package: indeksilo
indeksiloindeksilo allows to generate a multi-level alphabetical index from text in tabular data format.introductiontext in tabular data format is text formatted as a table (usually stored as a spreadsheet file), where each row of the table contains one word of the text.
one column contains the actual word as it appears in the text, while other columns may contain more information about the word, like the page and line number where it appears, a cleaned-up form (with uniform casing and no punctuation), its lemma, its grammatical category,…from text in that format, indeksilo generates an alphabetical index (like the ones that appear at the end of books).
see the example section below for a concrete example.featuresmulti-level index generationalphabetical sorting using the unicode collation algorithmright-to-left text supportmultiple values in parent columns support for agglutinated formsmultiple reference support (for example: page, line)grouping of identical references with counttotal count of form occurences at each parent levelfiltering with regular expressionsusageindeksilo takes an input filename and an output filename as arguments, as well as some options.
input and output files should be in opendocument (.ods) or office open xml (.xlsx) format.
the minimal usage is:indeksilo --ref-col ref --form-col form input.ods output.odswhererefis the title of the column (ininput.ods) that contains the reference to use in the index (the page number, for example) andformis title of the column (ininput.ods) that contains the form that will appear in the index.to display a full description of the usage syntax:indeksilo --helpexamplelet’s take the following example text, and say that it appears on line 1 and 2 of page 42:la suno brilas hodiaŭ. hieraŭ estis malvarme, sed hodiaŭ estas varme.ni estas bonŝancaj!it must first be converted to this format asinput.ods:pagelinewordformlemma421lalala421sunosunosuno421brilasbrilasbrili421hodiaŭ.hodiaŭhodiaŭ421hieraŭhieraŭhieraŭ421estisestisesti421malvarme,malvarmevarma421sedsedsed421hodiaŭhodiaŭhodiaŭ421estasestasesti421varme.varmevarma422ninini422estasestasesti422bonŝancaj!bonŝancajbona+ŝanconow, let’s generate the index by calling:indeksilo --ref-col page --ref-col line --parent-col lemma --form-col form --split-char + input.ods output.odsthis will generate the following table asoutput.ods:lemma_countlemmaform_countformrefs01bona1bonŝancaj42, 211brili1brilas42, 123esti2estas42, 1; 42, 231estis42, 141hieraŭ1hieraŭ42, 152hodiaŭ2hodiaŭ42, 1 (2)61la1la42, 171ni1ni42, 281ŝanco1bonŝancaj42, 291sed1sed42, 1101suno1suno42, 1112varma1malvarme42, 1121varme42, 1note that “bonŝancaj” appears twice in the index, once under the form “bona” and once under the form “ŝanco”.
this is because the lemma column contained two values, separated by the defined split character.note that the word “hodiaŭ” appears twice on the same line.
this is why its reference has “(2)” appended to it.filteringindeksilo allows to filter rows based on column values using regular expressions.for example, using the same input file as in the previous example, let’s say that only noun lemmas should appear.
in this case, they all end with “o”, so this command can be used:indeksilo --ref-col page --ref-col line --parent-col lemma --form-col form --split-char + --filter "lemma:.*o" input.ods output.odsin this example, the argument is quoted to avoid the*character to be interpreted by the shell.
this depends on the shell used.this will generate the following table:lemma_countlemmaform_countformrefs01ŝanco1bonŝancaj42, 211suno1suno42, 1note that “bonŝancaj” appears only once in this case, because the lemma “bona” was filtered out.multiple filter arguments may be used.
the format of the filter expressions iscol:regex, wherecolis a column name andregexis a regular expression matching the value (after splitting).
any column of the input table can be used, even those not used by the index.by default, filtering is inclusive, which means that at least one expression should match for the row to be included.
this behavior can be reversed with--filter-exclude.
in this case, any row matching an expression is excluded; only the rows not matching any of the expressions are included.for example, still using the same input file, let’s say that forms with less than 4 letters should be excluded.
this command can be used:indeksilo --ref-col page --ref-col line --parent-col lemma --form-col form --split-char + --filter "form:.{1,3}" --filter-exclude input.ods output.odsthis will generate the following table:lemma_countlemmaform_countformrefs01bona1bonŝancaj42, 211brili1brilas42, 123esti2estas42, 1; 42, 231estis42, 141hieraŭ1hieraŭ42, 152hodiaŭ2hodiaŭ42, 1 (2)61ŝanco1bonŝancaj42, 271suno1suno42, 182varma1malvarme42, 191varme42, 1indeksilo uses python’s regular expressions.
their documentation ishere.creditsThis development was funded by Bastien Kindt for the GREgORI Project.https://uclouvain.be/fr/instituts-recherche/incal/ciol/gregori-project.htmlhttps://www.v2.gregoriproject.com/