aspell-user
[Top][All Lists]
Advanced

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

RE: [Aspell-user] RE: Aspell-user Digest, Vol 24, Issue 23


From: Dormont, Dan \(Corporate\)
Subject: RE: [Aspell-user] RE: Aspell-user Digest, Vol 24, Issue 23
Date: Thu, 2 Dec 2004 17:10:41 -0500

I have done something similar (calling Aspell in pipe mode from Java).  The 
problem is the way you are trying to feed the file into Aspell.  I have not 
tried this, but I strongly suspect that the redirection characters "<", ">" and 
"|" do not work when calling Runtime.exec().  The reason, at least on Unix, is 
that these are shell metacharacters processed by the shell and not the 
underlying operating system.  This means that unless Java were invoking the 
command through a subshell (which it does not, to my knowledge) these tokens 
would be passed directly to aspell, which would not understand them.  I assume 
on Win32 it is similar.

Therefore the command you should pass to exec() is simply "aspell -a --llang=es 
--encoding=utf-8"

You then are responsibe for opening the text file and feeding it to the aspell 
process via the Process.getOutputStream() method (which is actually mapped to 
STDIN in the child process), and reading aspell's output via the 
Process.getInputStream() method (which is actually mapped to STDOUT in the 
child process).  Just to warn you:  it is *difficult* to get this right.  You 
need to always be sure to flush the data you are writing to the output stream, 
and you must calculate correctly how many lines to read from the input stream, 
or else your program will lock up.  Before you start working on this I highly 
recommend that you spend some time working with aspell -a on the command line 
to get familiar with its output.

In my program I fed the text to aspell one word at a time, which made things a 
bit easier, though I assume it's slower that way.

-Dan

-----Original Message-----
From: address@hidden
[mailto:address@hidden
Behalf Of keroppi kero
Sent: Wednesday, December 01, 2004 2:04 PM
To: address@hidden
Subject: [Aspell-user] RE: Aspell-user Digest, Vol 24, Issue 23


I'm sorry, I forgot the -a option in the comand wich I put in the mail. But 
I allready had usied this option. And my program go bad.

My program is writed in java. I create a new Process of aspell and then I 
read lines from InputStream, but my program can just read one line (the 
version of Aspell). Then, the readline is waiting for data. In the command 
line the call is that:

aspell -a --llang=es --encoding=utf-8 <c:\prueba.txt

and the output is correct.

But when I want to capture this output from the java code I can't do it.

My code java is this:

Runtime r = Runtime.getRuntime();
Process p = r.exec("aspell -a --lang=es --encoding=utf-8 <c:\\prueba.txt");
BufferedReader input = new BufferedReader(new 
InputStreamReader(p.getInputStream()));
System.out.println("xivato CmdExec(13)");
while ((line = input.readLine()) != null) {
        System.out.println(line);
        System.out.println(line);
}

the output of this code is one line with aspell info and then is waiting for 
more data (don't write suggs results)

(c:\prueba.txt have a incorrect word)

Have not anybody used aspell from java?

keroppi

_______________________________________________
Aspell-user mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/aspell-user




reply via email to

[Prev in Thread] Current Thread [Next in Thread]