Closed singh-lokendra closed 5 years ago
This was my line of thought
int argc
and char** argv
, which can be passed by using len(command)
and command
where type(command)
is <class 'list'>
and command
variable in similar format is already used in aperitum python https://github.com/apertium/apertium-python/blob/master/apertium/utils.py#L41they should be optional.
int argc
can be removed by using multi-argument typemap, then the wrapper calls can be made by simply passing command: list
I'm not actually super concerned with how the swig wrapper/python interface for directly calling this stuff looks since the apertium
python package wraps them up nicely anyway. It was a non-goal of this project to make these interfaces nice and usable.
What I'm more concerned with is that we're duplicating a bunch of logic here and just adding code that will get out of sync with the code that actually parses arguments for the CLI binaries. Thoughts?
What I'm more concerned with is that we're duplicating a bunch of logic here and just adding code that will get out of sync with the code that actually parses arguments for the CLI binaries. Thoughts?
Below is the list of various arguments used in mode files, Since these flags did required wrapping and ftyres didn't had all the pairs at that moment, I wrapped all of the arguments : ) https://github.com/apertium/apertium-python/issues/48
lt-proc
-b -c -d -e -p -w -x
lrx-proc
-m -t
apertium-interchunk
'', -t
apertium-postchunk
''
apertium-pretransfer
''
apertium-tagger
-g -p -u 2
apertium-transfer
-b -n -t
cg-proc
'' -n -w -1
fst.lt_proc(command, input_file.name, output_file.name)
but command
needs some arbitrary value at index[0] due to getopts, i.e command = ['lt-proc', '-w']
Duplicated logic is also a concern. It is absolutely possible to refactor the C++ code so that getopt()
and other option parsing is done in a shared 3rd function that Python can also make use of. But if that's too much work right now, it can be done later.
I feel OK merging this since the amount of duplicated code seems pretty small.
Will this (and https://github.com/apertium/apertium/pull/56 and https://github.com/apertium/apertium-lex-tools/pull/28) then require that all calls from Python provide
argc
andargv
? That would be cumbersome - they should be optional.