@@ -45,7 +45,7 @@ def deformatter(text: str) -> str:
45
45
"""
46
46
escape_chars = b'[]{}?^$@\\ '
47
47
_special_chars_map = {i : '\\ ' + chr (i ) for i in escape_chars }
48
- return '{}. [][\n ]' .format (text .translate (_special_chars_map ))
48
+ return '{}[][\n ]' .format (text .translate (_special_chars_map ))
49
49
50
50
51
51
def execute_pipeline (inp : str , commands : List [List [str ]]) -> str :
@@ -82,23 +82,29 @@ def execute_pipeline(inp: str, commands: List[List[str]]) -> str:
82
82
fst = lttoolbox .FST (dictionary_path )
83
83
if not fst .valid ():
84
84
raise ValueError ('FST Invalid' )
85
- fst .lt_proc (arg , input_file_name , output_file_name )
85
+ lt_proc_command = command [:- 1 ]
86
+ fst .lt_proc (len (lt_proc_command ), lt_proc_command , input_file .name , output_file .name )
86
87
elif 'lrx-proc' == command [0 ]:
87
88
dictionary_path = command [- 1 ]
88
89
lextools .LtLocale .tryToSetLocale ()
89
90
lrx = lextools .LRXProc (dictionary_path )
90
- lrx .lrx_proc (arg , input_file .name , output_file .name )
91
+ lrx_proc_command = command [:- 1 ]
92
+ lrx .lrx_proc (len (lrx_proc_command ), lrx_proc_command , input_file .name , output_file .name )
91
93
elif 'apertium-transfer' == command [0 ]:
92
- transfer = apertium_core .ApertiumTransfer (command [2 ], command [3 ])
93
- transfer .transfer_text (arg , input_file .name , output_file .name )
94
+ transfer = apertium_core .ApertiumTransfer (command [- 2 ], command [- 1 ])
95
+ transfer_command = command [:- 2 ]
96
+ transfer .transfer_text (len (transfer_command ), transfer_command , input_file .name , output_file .name )
94
97
elif 'apertium-interchunk' == command [0 ]:
95
- interchunk = apertium_core .ApertiumInterchunk (command [1 ], command [2 ])
96
- interchunk .interchunk_text (arg , input_file .name , output_file .name )
98
+ interchunk = apertium_core .ApertiumInterchunk (command [- 2 ], command [- 1 ])
99
+ interchunk_command = command [:- 2 ]
100
+ interchunk .interchunk_text (len (interchunk_command ), interchunk_command , input_file .name , output_file .name )
97
101
elif 'apertium-postchunk' == command [0 ]:
98
- postchunk = apertium_core .ApertiumPostchunk (command [1 ], command [2 ])
99
- postchunk .postchunk_text (arg , input_file .name , output_file .name )
102
+ postchunk = apertium_core .ApertiumPostchunk (command [- 2 ], command [- 1 ])
103
+ postchunk_command = command [:- 2 ]
104
+ postchunk .postchunk_text (len (postchunk_command ), postchunk_command , input_file .name , output_file .name )
100
105
elif 'apertium-pretransfer' == command [0 ]:
101
- apertium_core .pretransfer (arg , input_file .name , output_file .name )
106
+ command = ['apertium-pretransfer' , '' ]
107
+ apertium_core .pretransfer (len (command ), command , input_file .name , output_file .name )
102
108
elif 'apertium-tagger' == command [0 ]:
103
109
command += [input_file .name , output_file .name ]
104
110
apertium_core .ApertiumTagger (len (command ), command )
@@ -115,8 +121,8 @@ def execute_pipeline(inp: str, commands: List[List[str]]) -> str:
115
121
end = output_file .read ()
116
122
output_file .close ()
117
123
118
- os .remove (input_file_name )
119
- os .remove (output_file_name )
124
+ os .remove (input_file . name )
125
+ os .remove (output_file . name )
120
126
if not wrappers_available or not used_wrapper :
121
127
apertium .logger .warning ('Calling subprocess %s' , command [0 ])
122
128
proc = subprocess .Popen (command , stdin = subprocess .PIPE , stdout = subprocess .PIPE )
0 commit comments