Hi list,
Has anybody developped a way to check the existence of a word in a given dictionnary? As a basis, I was looking at the aspell command line spell checking tool : http://aspell.net/ This is well suited, but it will need to use the shell object and I'm working under OSX, so I'm not sure of it's long term stability. Aspell can be used as a lib also, so i was wondering if anyone has ever developped an external based on it? Or has anyone some other ideas to do that?
Thanks in advance,
Hallo, Nicolas Montgermont hat gesagt: // Nicolas Montgermont wrote:
Has anybody developped a way to check the existence of a word in a given dictionnary? As a basis, I was looking at the aspell command line spell checking tool : http://aspell.net/ This is well suited, but it will need to use the shell object and I'm working under OSX, so I'm not sure of it's long term stability. Aspell can be used as a lib also, so i was wondering if anyone has ever developped an external based on it? Or has anyone some other ideas to do that?
You could use Lua instead. It's like [shell] on steroids, if you employ something like "io.popen" like this:
word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all")
Lua is trivial to build on OS-X. I just did it and I'm a complete OS-X idiot. Here's how: You check out pdlua from goto10 subversion, edit Makefile.static to let it find m_pd.h and build for OS-X ("PLATFORM = macosx"), then do "make -f Makefile.static" while connected to the net to let make download and build Lua for you and that's it. OS-X seems to come with everything needed.
Frank Barknecht _ ______footils.org__
On Tue, Jul 15, 2008 at 07:17:48PM +0200, Frank Barknecht wrote:
Hallo, Nicolas Montgermont hat gesagt: // Nicolas Montgermont wrote:
Has anybody developped a way to check the existence of a word in a given dictionnary? As a basis, I was looking at the aspell command line spell checking tool : http://aspell.net/ This is well suited, but it will need to use the shell object and I'm working under OSX, so I'm not sure of it's long term stability. Aspell can be used as a lib also, so i was wondering if anyone has ever developped an external based on it? Or has anyone some other ideas to do that?
You could use Lua instead. It's like [shell] on steroids, if you employ something like "io.popen" like this:
word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all")
Lua is trivial to build on OS-X. I just did it and I'm a complete OS-X idiot. Here's how: You check out pdlua from goto10 subversion, edit Makefile.static to let it find m_pd.h and build for OS-X ("PLATFORM = macosx"), then do "make -f Makefile.static" while connected to the net to let make download and build Lua for you and that's it. OS-X seems to come with everything needed.
Hi Frank,
Did you have to install the XCode developer kit (or whatever it's called) to do this? Or is there a built in compiler? What version of OSX is it?
Thx for the help, sorry for the OT!
Chris.
On Tue, Jul 15, 2008 at 7:40 PM, Chris McCormick chris@mccormick.cx wrote:
On Tue, Jul 15, 2008 at 07:17:48PM +0200, Frank Barknecht wrote:
Hallo, Nicolas Montgermont hat gesagt: // Nicolas Montgermont wrote:
Has anybody developped a way to check the existence of a word in a given dictionnary? As a basis, I was looking at the aspell command line spell checking tool : http://aspell.net/ This is well suited, but it will need to use the shell object and I'm working under OSX, so I'm not sure of it's long term stability. Aspell can be used as a lib also, so i was wondering if anyone has ever developped an external based on it? Or has anyone some other ideas to do that?
You could use Lua instead. It's like [shell] on steroids, if you employ something like "io.popen" like this:
word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all")
Lua is trivial to build on OS-X. I just did it and I'm a complete OS-X idiot. Here's how: You check out pdlua from goto10 subversion, edit Makefile.static to let it find m_pd.h and build for OS-X ("PLATFORM = macosx"), then do "make -f Makefile.static" while connected to the net to let make download and build Lua for you and that's it. OS-X seems to come with everything needed.
Hi Frank,
Did you have to install the XCode developer kit (or whatever it's called) to do this? Or is there a built in compiler? What version of OSX is it?
Yo Chris, Ya, you'll need XCode to get gcc and friends... it is free on the install disc or you can download it after making a (free) account at http://connect.apple.com/ ; I think this info applies to all reasonably recent versions of OS X (10.3+ and perhaps earlier)
Cheers Luke
Thx for the help, sorry for the OT!
Chris.
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hallo, Chris McCormick hat gesagt: // Chris McCormick wrote:
On Tue, Jul 15, 2008 at 07:17:48PM +0200, Frank Barknecht wrote:
Lua is trivial to build on OS-X.
Did you have to install the XCode developer kit (or whatever it's called) to do this? Or is there a built in compiler? What version of OSX is it?
I didn't install the machines themselves. There already was a gcc-compiler, I don't know if this is part of some extra package only. But you need gcc and make, of course. OS-X was updated to the latest version, whatever that is, but the build was happening before the upgrade on whatever version that was. ;)
Sorry for not being able to be more specific, I'm away from these machines now.
Frank Barknecht _ ______footils.org__
Hi Frank,
Frank Barknecht a écrit :
Hallo,
You could use Lua instead. It's like [shell] on steroids, if you employ something like "io.popen" like this:
word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all")
Lua is trivial to build on OS-X. I just did it and I'm a complete OS-X idiot. Here's how: You check out pdlua from goto10 subversion, edit Makefile.static to let it find m_pd.h and build for OS-X ("PLATFORM = macosx"), then do "make -f Makefile.static" while connected to the net to let make download and build Lua for you and that's it. OS-X seems to come with everything needed.
Ciao
pdlua compile and load well here I think, console says:
lua 0.5 (GPL) 2008 Claude Heiland-Allen claudiusmaximus@goto10.org lua: compiled for pd-0.40 on Jul 16 2008 11:41:16
After that I wrote a little pd_luax object called lspell.pd_luax and containing:
local LSpell = pd.Class:new():register("lspell")
function LSpell:initialize(name, atoms) self.outlets = 1 self.inlets = 1 return true end
function LSpell:in_1_symbol(s) pd.post("received :" .. s) word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all") end
I know there is no output yet but the code is bugging at the get_word_from_inlet() function. When I do :
[symbol toto( | [lspell]
pd prints:
received :toto error: lua: error in dispatcher: [string "lspell.pd_luax"]:14: attempt to call global 'get_word_from_inlet' (a nil value)
I have no really idea of the way pdlua manage functions and everything. Must I dig more into the pd_lua examples or is this only a lua problem I can handle if searching universal lua docs?
Thanks for your answers,
Nicolas Montgermont wrote:
Hi Frank,
Frank Barknecht a écrit :
Hallo,
You could use Lua instead. It's like [shell] on steroids, if you employ something like "io.popen" like this:
word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all")
Lua is trivial to build on OS-X. I just did it and I'm a complete OS-X idiot. Here's how: You check out pdlua from goto10 subversion, edit Makefile.static to let it find m_pd.h and build for OS-X ("PLATFORM = macosx"), then do "make -f Makefile.static" while connected to the net to let make download and build Lua for you and that's it. OS-X seems to come with everything needed.
Ciao
pdlua compile and load well here I think, console says:
lua 0.5 (GPL) 2008 Claude Heiland-Allen claudiusmaximus@goto10.org lua: compiled for pd-0.40 on Jul 16 2008 11:41:16
After that I wrote a little pd_luax object called lspell.pd_luax and containing:
local LSpell = pd.Class:new():register("lspell")
This could be the problem, registering classes is usual in .pd_lua files but not .pd_luax files.
function LSpell:initialize(name, atoms) self.outlets = 1 self.inlets = 1 return true end
function LSpell:in_1_symbol(s) pd.post("received :" .. s) word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all") end
I know there is no output yet but the code is bugging at the get_word_from_inlet() function.
where did you define get_word_from_inlet? You should just be able to use 's', as that's the symbol atom passed to the inlet method.
When I do :
[symbol toto( | [lspell]
pd prints:
received :toto error: lua: error in dispatcher: [string "lspell.pd_luax"]:14: attempt to call global 'get_word_from_inlet' (a nil value)
I have no really idea of the way pdlua manage functions and everything. Must I dig more into the pd_lua examples or is this only a lua problem I can handle if searching universal lua docs?
This seems to be a Lua problem more than a pdlua problem - you use get_word_from_inlet() but don't define it anywhere.
A pdlua manual is on my todo list, but for now the examples are the best documentation.
Thanks for your answers,
Nicolas
Hope this helps,
Claude Heiland-Allen a écrit :
local LSpell = pd.Class:new():register("lspell")
This could be the problem, registering classes is usual in .pd_lua files but not .pd_luax files.
I haven't really understood how to build a pd_luax file then... nevermind.
function LSpell:initialize(name, atoms) self.outlets = 1 self.inlets = 1 return true end
function LSpell:in_1_symbol(s) pd.post("received :" .. s) word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all") end
I know there is no output yet but the code is bugging at the get_word_from_inlet() function.
where did you define get_word_from_inlet? You should just be able to use 's', as that's the symbol atom passed to the inlet method.
mmh sure, I just used that cause that was the part of code frank mentionned and thought this was a kind of pd secure-interacting functions.
When I do :
[symbol toto( | [lspell]
pd prints:
received :toto error: lua: error in dispatcher: [string "lspell.pd_luax"]:14: attempt to call global 'get_word_from_inlet' (a nil value)
I have no really idea of the way pdlua manage functions and everything. Must I dig more into the pd_lua examples or is this only a lua problem I can handle if searching universal lua docs?
This seems to be a Lua problem more than a pdlua problem - you use get_word_from_inlet() but don't define it anywhere.
A pdlua manual is on my todo list, but for now the examples are the best documentation.
I manage to get it work with this code:
function LSpell:in_1_symbol(s) word = s
cmd = "echo " .. word .. " | /sw/bin/ispell -a | grep \\*"
p = assert(io.popen(cmd))
result = p:read("*all")
if(string.len(result) ~= 0) then
self:outlet(1, "symbol", {word})
end
end
It outputs the word only if it exists in ispell.
Can Lua be used as a more stable shell interpretor for all the functions? It is of a big interest!!
Thanks to all,
Nicolas
Hi Claude adn list,
Back again with my spelling function written in lua. I've got a problem in the terminal sometimes (pretty often in fact) :
error: lua: error in dispatcher: [string "lspell"]:13: echo fhdkq | /sw/bin/ispell -a | grep \*: Too many open files
when using my object "lspell.pd_lua", feeding the inlet with [symbol fhdkq( for example. When this error appears the object is not working. This error occurs in groups : appearing for 5-20 seconds and disappearing for 10 - 60 seconds. What exactly is this error? I guess this is a kind of overflow of the usage lua can make of the terminal, but I was wandering if there is some workaround technique to avoid this? Has someone an idea of the time one must wait between two usage of the same object? My current code is:
local LSpell = pd.Class:new():register("lspell")
function LSpell:initialize(name, atoms) self.outlets = 1 self.inlets = 1 return true end
function LSpell:in_1_symbol(s) local word = s
local cmd = "echo " .. word .. " | /sw/bin/ispell -a | grep \\*"
local p = assert(io.popen(cmd))
local result = p:read("*all")
if(string.len(result) ~= 0) then
self:outlet(1, "symbol", {word})
end
end
Thanks in advance,
Nicolas
Hallo, Nicolas Montgermont hat gesagt: // Nicolas Montgermont wrote:
function LSpell:in_1_symbol(s) pd.post("received :" .. s) word = get_word_from_inlet() cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all") end
I know there is no output yet but the code is bugging at the get_word_from_inlet() function.
Yeah, sorry, that's probably my fault. My little Lua example was meant to be a kind of pseudo-code, sorry. But I see that you already solved the issue with Claude's help.
Btw. other than in Python or C, variables are global as default in Lua. I also didn't include it in my "pseudo-code" but instead of this:
cmd = "aspell -c " .. word p = assert(io.popen(cmd)) result = p:read("*all")
you should declare variables as "local" like this:
local cmd = "aspell -c " .. word local p = assert(io.popen(cmd)) local result = p:read("*all")
Sorry for adding confusion like this.
Frank