[PD] Spell checking / existence of a word
Nicolas Montgermont
nicolas_montgermont at yahoo.fr
Wed Jul 16 14:18:12 CEST 2008
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
--
http://nim.on.free.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20080716/0792b820/attachment.htm>
More information about the Pd-list
mailing list