[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lojban] Re: Parsers won't compile in Linux



On 9/24/08, Philip Newton <philip.newton@gmail.com> wrote:

> > It took me a long time to realize that the lojban sentence was
> > not supposed to be typed along with the command as in: "jbofihe
> > sentence". Instead you have to give "jbofihe filename", where
> > filename is the name of a textfile containing the lojban text
> > jbofi'e will parse.

> Or just "jbofihe", then type Lojban at the program, then Ctrl-D.
> (My preferred method.)
>
>  Or "echo 'mi klama le zarci' | jbofihe".

Long ago I have written a short python script that adds the readline
capabilities to jbofihe: you can type the lojban text, recall the text
previously typed by the up arrow, edit it and so on. Very handy if you
are trying to say something in lojban and are not sure about the
correct way to do this. Because some lojban sentences are very long
(and because you are often paste them from some other window), "end of
sentence" is not the one newline, but two in a row (like a paragraph).

Alas script was debugged with Win32 python, not with Linux one, but it
seems like there is nothing Win32-specific in it. Anyway it is short,
and you can give a try to it -- if it doesn't work, you lose nothing.
Script text follows:

import atexit, os, readline, sys

histfilename = "citri.jbo"

def input_para(ps1 = "", ps2 = ""):
    para = ""
    line = raw_input(ps1)
    while line != "":
        para += line + "\n"
        line = raw_input(ps2)
    return para

readline.read_history_file(histfilename)
readline.set_history_length(500)
atexit.register(readline.write_history_file, histfilename)

try:
    while 1:
        text = input_para(">> ", ".. ")
        inpipe, outpipe, errpipe = os.popen3("jbofihe -b -x")
        inpipe.write(text)
        inpipe.close()
        sys.stdout.write(outpipe.read())
        outpipe.close()
        sys.stdout.write(errpipe.read())
        errpipe.close()
except EOFError:
    sys.stdout.write("co'o")

-- 
http://slobin.pp.ru/ `When I use a word,' Humpty Dumpty said,
<cyril@slobin.pp.ru> `it means just what I choose it to mean'


To unsubscribe from this list, send mail to lojban-list-request@lojban.org
with the subject unsubscribe, or go to http://www.lojban.org/lsg2/, or if
you're really stuck, send mail to secretary@lojban.org for help.