convertermanager
This file manages conversion of files to the Giella xml format.
ConverterManager
Manage the conversion of original files to corpus xml.
Class/static variables: _languageguesser (text_cat.Classifier): Language guesser to indicate languages in the converted document. Attributes: write_intermediate (bool): indicate whether intermediate versions of the converted document should be written to disk. goldstandard (bool): indicating whether goldstandard documents should be converted. files (list of str): list of paths to original files that should be converted from original format to xml.
Source code in corpustools/convertermanager.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
__init__(lazy_conversion=False, write_intermediate=False, goldstandard=False)
Initialise the ConverterManager class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lazy_conversion
|
bool
|
indicate whether conversion depends on the fact that metadata have changed since last conversion. |
False
|
write_intermediate
|
bool
|
indicating whether intermediate versions of the converted document should be written to disk. |
False
|
goldstandard
|
bool
|
indicating whether goldstandard documents should be converted. |
False
|
Source code in corpustools/convertermanager.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
collect_files(sources)
Find all convertible files in sources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sources
|
list of str
|
a list of files or directories where convertable files are found. |
required |
Source code in corpustools/convertermanager.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
convert(orig_file)
Convert file to corpus xml format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orig_file
|
CorpusPath
|
the path to the original file. |
required |
Source code in corpustools/convertermanager.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
convert_in_parallel(pool_size)
Convert files using the multiprocessing module.
Source code in corpustools/convertermanager.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
convert_serially()
Convert the files in one process.
Source code in corpustools/convertermanager.py
123 124 125 126 127 128 129 | |
corpus_paths(sources)
Yield all convertible files in sources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sources
|
list of str
|
a list of files or directories where convertable files are found. |
required |
Yields: Convertible files found in sources.
Source code in corpustools/convertermanager.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
languageguesser()
Return our language guesser. This is a class variable, but since it takes a while to initialise, we don't do it until it's needed.
Source code in corpustools/convertermanager.py
52 53 54 55 56 57 58 | |
main()
Convert documents to giellatekno xml format.
Source code in corpustools/convertermanager.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
parse_options()
Parse the commandline options.
Returns:
| Type | Description |
|---|---|
Namespace
|
the parsed commandline arguments |
Source code in corpustools/convertermanager.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
sanity_check()
Check that needed programs and environment variables are set.
Source code in corpustools/convertermanager.py
234 235 236 237 238 239 240 241 242 243 244 | |
unwrap_self_convert(arg, **kwarg)
Unpack self from the arguments and call convert again.
This is due to how multiprocess works: http://www.rueckstiess.net/research/snippets/show/ca1d7d90
Source code in corpustools/convertermanager.py
171 172 173 174 175 176 177 | |