avvirconverter
Convert Ávvir-files to the Giella xml format.
convert2intermediate(filename)
Convert Ávvir xml files to the giellatekno xml format.
The root node in an Ávvir document is article. article nodes contains one or more story nodes. story nodes contain one or more p nodes. p nodes contain span, br and (since 2013) p nodes.
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
convert_article(avvir_doc)
The root element of an Ávvir doc is article, rename it to body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
avvir_doc |
etree.Element
|
the etree that should be manipulated. |
required |
Returns:
Type | Description |
---|---|
etree.Element
|
The document root of the basic Giella xml document. |
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
convert_p(avvir_doc)
Convert story/p elements to one or more p elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
avvir_doc |
etree.Element
|
the etree that should be manipulated. |
required |
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
convert_story(avvir_doc)
Convert story elements in to giellatekno xml elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
avvir_doc |
etree.Element
|
the etree that should be manipulated. |
required |
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
convert_sub_p(para)
Convert p element found inside story/p elements.
These elements contain erroneous text that an editor has removed. This function removes p.text and saves p.tail
Parameters:
Name | Type | Description | Default |
---|---|---|---|
para |
lxml.etree.Element
|
an lxml element, it is a story/p element |
required |
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
convert_subelement(para)
Convert subelements of story/p elements to p elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
para |
lxml.etree.Element
|
an lxml element, it is a story/p element |
required |
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
fix_quotemarks(avvir_doc)
Ávvir has funky quotemarks that seem to be a conversion error from their side.
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
172 173 174 175 176 177 178 179 180 181 |
|
insert_element(para, text, position)
Insert a new element in p's parent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
para |
lxml.etree.Element
|
an lxml element, it is a story/p element |
required |
text |
str
|
string |
required |
position |
int
|
the position inside p's parent where the new element is inserted |
required |
Returns:
Type | Description |
---|---|
int
|
the position |
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
remove_identical_ids(avvir_doc)
Remove identical ids.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
avvir_doc |
etree.Element
|
the etree that should be manipulated. |
required |
Source code in /home/anders/projects/CorpusTools/corpustools/avvirconverter.py
23 24 25 26 27 28 29 30 31 32 33 34 35 |
|