Questions about a few functions that I can't find documentation for

14 views
Skip to first unread message

JRowe

unread,
Nov 16, 2010, 5:19:29 PM11/16/10
to link-grammar
I'm finishing up a Lua wrapper for LGP, and I encountered a few
functions that aren't documented, and that I can't find references to.

prt_error
lperrmsg
lperrno
lperror_clear
parse_options_print_total_time

Could someone let me know what parameters those functions take, and
their return types?

The Lua wrapper should work on any platform that supports Alien:
http://alien.luaforge.net/ , and I've tried to document (minimally,
sometimes copying straight from the site) each function and provide a
demonstration of usage.

JRowe

unread,
Nov 16, 2010, 8:13:50 PM11/16/10
to link-grammar
Speaking of the Lua wrapper, I've uploaded the source and I'll set up
svn at some point, as well as the Windows binary package in a zip
archive (thank you Simon Stuart!)

I'll add some more text and a readme later on.

http://code.google.com/p/lualinkgrammar/

Linas Vepstas

unread,
Nov 16, 2010, 11:07:42 PM11/16/10
to link-g...@googlegroups.com
On 16 November 2010 16:19, JRowe <jro...@gmail.com> wrote:
> I'm finishing up a Lua wrapper for LGP, and I encountered a few
> functions that aren't documented, and that I can't find references to.
>
> prt_error

internal use only; do not use.

> lperrmsg
> lperrno
> lperror_clear

all three are obsolete, and do nothing at all. They're only there to allow
very old programs to link & run.

> parse_options_print_total_time

ehh. The parse_options are poorly defined. About half of them affect
the parser; the other half don't affect the parser at all, but are only used
by the command-line tool to control printing, display. Its not clearly
documented which is which; the two sets of options should be split apart;
haven't had much need to yet.

> Could someone let me know what parameters those functions take, and
> their return types?

Do not wrap any of these.

> The Lua wrapper should work on any platform that supports Alien:
> http://alien.luaforge.net/ , and I've tried to document (minimally,
> sometimes copying straight from the site) each function and provide a
> demonstration of usage.

I've taken a quick look. Now, link-grammar is object-oriented in it's API;
but I got no sense of this at all in the lua wrapper. Isn't lua an OO language?

So for example, I see this lua code:


-- Func: LGP.linkage_get_word(pointer Linkage, int Index)

-- Desc: This function returns the inflected word at Linkage[Index]

-- Use : word = LGP.linkage_get_word(linkage, 1)

LGP.linkage_get_word:types{ret = "string", abi= "cdecl", "pointer", "int"}

In the C API, "pointer Linkage" is actually just "pointer this", so
I expected to see Linkage as an object, and you would call
the "get_word" method on this object. The pointer to "this" or "self",
its an opaque object and should be invisible in every language except C.
(because in C, "this" has to be always visible/explicit, as the first
arg to every
function call). Right? Makes sense?

Now, there might be some odd-ball routines in the C API that might not
fit the true OO model cleanly, but I can't recall what these are off-hand,
they're probably inconsequential. As you hit these, I can fix/deprecate
them as needed.

--linas

Linas Vepstas

unread,
Nov 16, 2010, 11:17:04 PM11/16/10
to link-g...@googlegroups.com
On 16 November 2010 19:13, JRowe <jro...@gmail.com> wrote:
> Speaking of the Lua wrapper, I've uploaded the source and I'll set up
> svn at some point, as well as the Windows binary package in a zip
> archive (thank you Simon Stuart!)

Not to be pushy, but I'd like to see both windows and linux lua bindings.

I mean, I know that you know that I think that programming in Windows
is about as pleasant as hitting ones fingers with a hammer. ... but really,
still bashing away?

-- Linas

Josh Rowe

unread,
Nov 17, 2010, 12:37:54 AM11/17/10
to link-g...@googlegroups.com
Lol, Windows isn't that bad. :P

Lua directly into a directory and replace LGP.dll with LGP.so (or whatever the linux binary name is.) Everything else should be identical. I'll make a Linux binary archive shortly, packaged the same way. I also need to include Alien.lua so it can be a standalone project, and perhaps create a crossplatform GUI example.

Lua isn't OO, even though it can be... I'll test those calls, and adjust where needed, however the Alien library which I used to wrap the lib is functionally identical to DllCall in AutoIt - there's no particular formal way to express calls to (this), there's just a requirement to correctly type the parameter and return.

Thanks for clarification on those functions. There are a few new features to the API that I'm looking forward to using, like the spellcheck feature, and Lua has made it almost trivial (if a tad tedious.)


Linas Vepstas

unread,
Nov 17, 2010, 1:09:46 AM11/17/10
to link-g...@googlegroups.com
On 16 November 2010 23:37, Josh Rowe <jro...@gmail.com> wrote:
> Lol, Windows isn't that bad. :P

Maybe you've never used it .. oh, wait ...

> Lua directly into a directory and replace LGP.dll with LGP.so (or whatever
> the linux binary name is.) Everything else should be identical. I'll make a
> Linux binary archive shortly, packaged the same way. I also need to include
> Alien.lua so it can be a standalone project,

Well, I'm a big believer in one-stop shopping, so if it makes sense to include
some part with link-grammar, let me know ...

> Lua isn't OO, even though it can be... [...] there's no particular formal


> way to express calls to (this),

Oh. Huh. ok.

--linas

p.s. as to windows dll's ... note that link-grammar ships with the abiword
word-processor, so they presumably ship windows dll's as well. Just
maybe not the header files & etc.

--linas

Simon J Stuart

unread,
Nov 17, 2010, 4:31:30 AM11/17/10
to link-g...@googlegroups.com
JRowe,
You're welcome... funnily enough I too have produced a complete Lua wrapper
for the LGP on Windows! I did it for Rich Cooper's work when he gets around
to that particular stage of development.

Regards,
Simon J Stuart

http://code.google.com/p/lualinkgrammar/

--
You received this message because you are subscribed to the Google Groups
"link-grammar" group.
To post to this group, send email to link-g...@googlegroups.com.
To unsubscribe from this group, send email to
link-grammar...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/link-grammar?hl=en.

Simon J Stuart

unread,
Nov 17, 2010, 4:37:51 AM11/17/10
to link-g...@googlegroups.com
Linas,
My Lua wrapper for the LGP is not a compiled binary... I've written a
Foreign Function Interface for Lua which compiles under Windows, Linux, and
Mac... on x86, x64 AND ARM platforms... put simply: my LGP Lua binding is
written entirely as native Lua code, and since the FFI plugin for Lua I've
produced can be built natively under the aforementioned platforms, the
binding will work on any platform... it automatically determines if it's a
.dll, .so, or .dylib (if I'm remembering that properly)...

The FFI itself isn't 100% ready for a public release, but as soon as it is
I'll be releasing a completely new development system which uses nothing but
Lua at the implementation level... with a comprehensive RTL and VCL (Visual
Component Library) and a cross-platform IDE (currently in development)....
the LGP wrapper unit will be a part of the package :)

I may actually be able to send you an x86 Linux build of the system with the
Lua wrapper and a test implementation so you can let me know what you
think... I'll get back to you as soon as I have time to do another Linux
build and test (which means pulling my 'nix box out of storage)

Regards,
Simon

-----Original Message-----
From: link-g...@googlegroups.com [mailto:link-g...@googlegroups.com]

-- Linas

--

Rich Elk

unread,
Nov 17, 2010, 12:26:44 PM11/17/10
to link-g...@googlegroups.com
And I have to comment about this; Simon's work is excellent quality and the
LGP works fine from Delphi 7, my favorite coding platform. I haven't had
time to fully utilize the LGP yet, but all the code I have written drives
the LGP nicely. I am still waiting to figure out what the new Kinect sensor
has in speech input and output (hopefully text that can be interfaced with
the LGP) as well as in tracking of gestures. That is where I hope to apply
the LGP with Simon's Lua wrapper when the time is ripe.

Does anyone have experience with Kinect yet?

HTH,
-Rich

Sincerely,
Rich Cooper
EnglishLogicKernel.com
Rich AT EnglishLogicKernel DOT com
9 4 9 \ 5 2 5 - 5 7 1 2

Linas Vepstas

unread,
Nov 17, 2010, 2:17:04 PM11/17/10
to link-g...@googlegroups.com
On 17 November 2010 03:37, Simon J Stuart <kra...@greycascade.com> wrote:
> Linas,
> My Lua wrapper for the LGP is ...

Well, having two lua wrappers in the world is maybe one-too-many,
is it possible to consolidate/merge/pick-best-of the two wrappers?

> I may actually be able to send you an x86 Linux build of the system

Don't; I almost surely will not do anything with it. But posting
source/binaries for the world is encouraged.

--linas

Josh Rowe

unread,
Nov 17, 2010, 7:06:16 PM11/17/10
to link-g...@googlegroups.com
Alien, what I used to wrap the API, is a cross platform foreign function interface. The file "LGP.lua" that I uploaded will work on Windows, Mac, Linux, and any other platform that Alien supports. All that needs to be changed is the name of the binary in the first line.

You can get Alien by doing: luarocks install alien
I'll add it to the package, and add the linux and mac versions. I'll add an Android version, as well, if I can get LinkGrammar to compile on the NDK without my brain imploding.

Also, Lua does have a way of calling self, using method calls. I'll look into reworking the way I have things set up - It'd be much easier to do MySentence:split() than to do LGP.sentence_split(pointerToMySentence)

I'm not sure that I can use method calls to reference the correct pointers, but I can definitely set up the library for easier use. Be as pushy as you want, Linas - I don't mind being corrected.

Also, do you want to combine our efforts, Simon? I'll have svn set up on the google code page tonight, and can set you up as a project owner. I'd like to see your approach to this as well, for my  own personal education.
Reply all
Reply to author
Forward
0 new messages