$ curl http://termbin.com/sah4 >pres2pret.py
$ curl https://raw.githubusercontent.com/goavki/streamparser/master/streamparser.py >streamparser.py $ sudo apt install apertium-nno $ echo 'ååh hald no opp, eg gjer det etter kvart.' |\ apertium-deshtml -n |\ lt-proc /usr/share/apertium/apertium-nno/nno.automorf.bin |\ cg-proc -1 /usr/share/apertium/apertium-nno/nno.rlx.bin |\ python3 pres2pret.py |\ lt-proc -g /usr/share/apertium/apertium-nno/nno.autogen.bin |\ apertium-rehtml-noent which gives the (rather ungrammatical) answer "ååh hald no opp, eg gjorde det etter kvart". Per Tunedal <[email protected]> čálii: > Hi all of you, > can Apertium be used to change tense in a text? > > Scenario: > > I've written a text of some hundred pages in e.g. past tense and would > like to have it in present (or the other way around). > > I suppose all information needed is in the monolingual dictionary for > the language in question. We've got an analyser and a generator. > > The question is: > > How do I put this together to: > > - analyse a monolingual text > - change the tense of the verbs as needed > - generate the text with the chosen tense > > Yours, > Per Tunedal
#!/usr/bin/env python3
import sys
from streamparser import parse_file, readingToString, known, SReading
for blank, lu in parse_file(sys.stdin, withText=True):
pres = [s for r in lu.readings for s in r if s.tags == ['vblex', 'pres']]
if pres != []:
pret = [SReading(baseform=s.baseform, tags=['vblex', 'pret'])
for s in pres]
print(blank+" ".join("^{}$".format(readingToString(pret))
for r in lu.readings),
end="")
else:
print(blank+"["+lu.wordform+"]",
end="")
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Apertium-stuff mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/apertium-stuff
