Sed in modes doesn't work
<mode name="quc-morph" install="yes">
<pipeline>
<program name="sed "s/['’]/ʼ/g""/>
<program name="hfst-proc -w">
<file name="quc.automorf.hfst"/>
</program>
</pipeline>
</mode>
Result:
>>> apertium.Analyzer('quc')
<apertium.analysis.Analyzer object at 0x7f27c4bfb190>
>>> a = apertium.Analyzer('quc')
>>> a.analyse('we')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Analyzer' object has no attribute 'analyse'
>>> a.analyze('we')
sed: -e expressió #1, caràcter 1: ordre desconeguda: «"»
[]
The mode parsing code is https://github.com/apertium/apertium-python/blob/master/apertium/utils.py#L189-L197 - the sed "s/['’]/ʼ/g" gets parsed as sed with arg "s/[’]/ʼ/g" and later executed as command sed with escaped argument '"s/[’]/ʼ/g"' - that is, ' is removed and the whole argument is wrapped in ', and this is correct behavior for raw commands to make them safe to execute. Working as intended and as required.
As the code says, "we should make language pairs install modes.xml instead" - but that wouldn't help with literal ' in the args.
This goes way back. I noted on 2014-01-16: "Btw, modes.xml is broken by design. You can't use it without extra parsing and it can't handle program names with spaces in. It should be <program name="what ever"><arg name="-x"/><arg name="-y">value</arg></program>" or similar. Need to clearly denote the program name and each arg in the XML.