Keeping PowerLoom around as a daemon?

View: New views
11 Messages — Rating Filter:   Alert me  

Keeping PowerLoom around as a daemon?

by Rich Morin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think I asked some similar questions several years ago, but
many of the details have no doubt changed on all sides.  So...


I'm interested in being able to "load up" a PL instance with a
bunch of information, ask questions of it, then adjust the set
of information, ask more questions, etc.  My language of choice
is Ruby, but I'm willing to generate and parse KIF or other
formats, if need be.

Could someone give me a hand-waving summary of how one might
approach this, what pitfalls to consider, etc?  My need isn't
imminent, but I'd like to know if I'm depending on something
that may not be all that easy to make work.

-r
--
http://www.cfcl.com/rdm            Rich Morin
http://www.cfcl.com/rdm/resume     rdm@...
http://www.cfcl.com/rdm/weblog     +1 650-873-7841

Technical editing and writing, programming, and web development
_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: Keeping PowerLoom around as a daemon?

by Thomas Russ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 17, 2008, at 7:55 PM, Rich Morin wrote:

> I think I asked some similar questions several years ago, but
> many of the details have no doubt changed on all sides.  So...
>
> I'm interested in being able to "load up" a PL instance with a
> bunch of information, ask questions of it, then adjust the set
> of information, ask more questions, etc.  My language of choice
> is Ruby, but I'm willing to generate and parse KIF or other
> formats, if need be.
>
> Could someone give me a hand-waving summary of how one might
> approach this, what pitfalls to consider, etc?  My need isn't
> imminent, but I'd like to know if I'm depending on something
> that may not be all that easy to make work.

There are a couple of options.  I'm not sure what sort of integration  
Ruby might have with Java or C++, so some of this may or may not work.

1.  Just create a combined application.  If Ruby supports easy  
integration with C++, then you can just load the C++ libraries and run  
a combined application that includes PowerLoom.

2.  Use a tcp-stream based server.  We have a Java class  
edu.isi.powerloom.logic.PowerLoomServer that implements a simple tcp-
stream based listener.   You would start up a Java process with the  
server and have it load your knowledge base.  It then begins listening  
for tcp connections on a port you specify.   You send commands and  
queries to server and it gives answers back.  This is the simplest  
server-based solution.

3.  You could use the PowerLoom SOAP server to handle the  
interactions.  This is a bit more involved, and I don't think we have  
that code in the standard distribution -- mainly because we haven't  
really written the documentation on how to set it up.  But that would  
allow you to use PowerLoom as a web service.


_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: Keeping PowerLoom around as a daemon?

by Hans Chalupsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Rich,

since you are using Ruby, you might also want to have a look at Mark
Watson's blog pages, since he has generated JRuby bindings for
PowerLoom:

http://www.markwatson.com/opensource/

Just as a clarification from reading your second paragraph: in order
to "load up" PowerLoom with knowledge and query it, change the KB,
etc. you will need to generate KIF, since that's the content language
PowerLoom uses to represent and query knowledge.

Ruby or whatever other programming language you choose is used only to
interface with the PowerLoom API and your particular application,
e.g., to programmatically execute an assertion, retraction or query.

Hans

>>>>> Thomas Russ <tar@...> writes:

> On Jun 17, 2008, at 7:55 PM, Rich Morin wrote:

>> I think I asked some similar questions several years ago, but
>> many of the details have no doubt changed on all sides.  So...
>>
>> I'm interested in being able to "load up" a PL instance with a
>> bunch of information, ask questions of it, then adjust the set
>> of information, ask more questions, etc.  My language of choice
>> is Ruby, but I'm willing to generate and parse KIF or other
>> formats, if need be.
>>
>> Could someone give me a hand-waving summary of how one might
>> approach this, what pitfalls to consider, etc?  My need isn't
>> imminent, but I'd like to know if I'm depending on something
>> that may not be all that easy to make work.

> There are a couple of options.  I'm not sure what sort of integration  
> Ruby might have with Java or C++, so some of this may or may not work.

> 1.  Just create a combined application.  If Ruby supports easy  
> integration with C++, then you can just load the C++ libraries and run  
> a combined application that includes PowerLoom.

> 2.  Use a tcp-stream based server.  We have a Java class  
> edu.isi.powerloom.logic.PowerLoomServer that implements a simple tcp-
> stream based listener.   You would start up a Java process with the  
> server and have it load your knowledge base.  It then begins listening  
> for tcp connections on a port you specify.   You send commands and  
> queries to server and it gives answers back.  This is the simplest  
> server-based solution.

> 3.  You could use the PowerLoom SOAP server to handle the  
> interactions.  This is a bit more involved, and I don't think we have  
> that code in the standard distribution -- mainly because we haven't  
> really written the documentation on how to set it up.  But that would  
> allow you to use PowerLoom as a web service.


> _______________________________________________
> powerloom-forum mailing list
> powerloom-forum@...
> http://mailman.isi.edu/mailman/listinfo/powerloom-forum
_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Parent Message unknown Re: Keeping PowerLoom around as a daemon?

by Rich Morin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

To clarify my intent, I'm after the ability to manipulate data
structures in Ruby, before and/or after they have been sent to
PowerLoom.  My take is that KIF is simply a way of expressing
"lists of lists".  So, I should be able to use Ruby syntax to
express the same structures.


At the risk of exposing my utter ignorance, here's a straw man:

To get from KIF to Ruby:

  Turn parentheses into brackets.
  Separate terms by commas.
  Precede each word by a colon.
  Leave numbers alone.
  Wrap other terms in quotes.


So, the KIF statement:

  ( retrieve
    10
    ( ?x    Person )
    ( happy ?x )
  )

would become the Ruby structure (list of lists):

  [ :retrieve,
    10,
    [ "?x",   :Person ],
    [ :happy, "?x" ]
  ]


Using irb (interactive Ruby), I can now manipulate this:

  >> k = [:retrieve, 10, ["?x", :Person], [:happy, "?x"]]

  >> puts k[2].inspect
  ["?x", :Person]

  >> puts k[3][0].inspect
  :happy


So, what am I missing, on the syntax front?

-r


P.S.

I used these references:

  http://suo.ieee.org/SUO/KIF/suo-kif.html
  http://www.isi.edu/isd/LOOM/PowerLoom-work/documentation/manual_body.html

The Ruby syntax :xyz defines a "symbol", which is an
immutable, unique string.


--
http://www.cfcl.com/rdm            Rich Morin
http://www.cfcl.com/rdm/resume     rdm@...
http://www.cfcl.com/rdm/weblog     +1 650-873-7841

Technical editing and writing, programming, and web development
_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: Keeping PowerLoom around as a daemon?

by Rich Morin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

After looking more closely at the KIF documentation, I realized
that my first thought (textual substitutions using RegExps and
Ruby code) wasn't going to be very robust, maintainable, etc.

So, I asked around for a Ruby-based parsing library.  I settled
on Treetop, which uses parsing expression grammars to generate
parsers that Ruby can execute.  This weekend, I pulled together
a first cut at a KIF parser.  With the exception of comments, it
can parse (my impression of) the KIF syntax:

  http://cfcl.com/twiki/bin/view/Projects/Arti/Patterns/RubyKif_H2

While I work on parsing comments and emitting KIF generally, I'm
hoping that some folks here will be willing to look over my notes
and let me know if I'm missing (or misinterpreting) anything.

-r
--
http://www.cfcl.com/rdm            Rich Morin
http://www.cfcl.com/rdm/resume     rdm@...
http://www.cfcl.com/rdm/weblog     +1 650-873-7841

Technical editing and writing, programming, and web development
_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Parent Message unknown Re: Keeping PowerLoom around as a daemon?

by Rich Morin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

RubyKif now emits KIF, as well.

  http://cfcl.com/twiki/bin/view/Projects/Arti/Patterns/RubyKif_H2

-r
--
http://www.cfcl.com/rdm            Rich Morin
http://www.cfcl.com/rdm/resume     rdm@...
http://www.cfcl.com/rdm/weblog     +1 650-873-7841

Technical editing and writing, programming, and web development
_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: Keeping PowerLoom around as a daemon?

by Thomas Russ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 22, 2008, at 5:21 PM, Rich Morin wrote:

>   http://cfcl.com/twiki/bin/view/Projects/Arti/Patterns/RubyKif_H2
>
> While I work on parsing comments and emitting KIF generally, I'm
> hoping that some folks here will be willing to look over my notes
> and let me know if I'm missing (or misinterpreting) anything.

In general this looks pretty good, but I'm not familiar with Ruby at  
all, so take that for what it's worth.  I see you have introduced  
some mechanism for handling characters that aren't supported in Ruby  
symbol names.

I will note that there are some areas where PowerLoom is a bit  
different from KIF, but they are fairly minor.

One is that PowerLoom will use "keyword symbols" which are symbols  
that start with a colon.  This is often used to specify options to  
various PowerLoom commands, such as definitions like:

   (defconcept person (?x) :=> (animal ?x))

   (retrieve all (person ?x) :dont-optimize? true)
      ;; Note the "?" at the end of the keyword.

Also, one difference is that Stella (and by extension PowerLoom) uses  
the "@" marker for different purposes than KIF.  Normally you  
shouldn't encounter any @-symbols in PowerLoom.  But we don't use  
them for row variables.  Instead they identify surrogate symbols.




_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: Keeping PowerLoom around as a daemon?

by Rich Morin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

As I read Thomas's remarks:

  *  @foo is still going to show up; it will just mean something
     else.  Not an issue at this point.

  *  Some words may be followed by question marks, as:

     *  foo?,  :bar?

  *  Some words and symbols may be preceded by colons, as:

     *  :foo,

     *  :=, :=>, and :<=>

Anything else?  Any mistakes?

-r
--
http://www.cfcl.com/rdm            Rich Morin
http://www.cfcl.com/rdm/resume     rdm@...
http://www.cfcl.com/rdm/weblog     +1 650-873-7841

Technical editing and writing, programming, and web development
_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

pointer to some PL-generated KIF?

by Rich Morin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm wondering if anyone can point me to a fairly substantial
body of PL-generated KIF.  I'd like to use it to check out my
parser.

-r
--
http://www.cfcl.com/rdm            Rich Morin
http://www.cfcl.com/rdm/resume     rdm@...
http://www.cfcl.com/rdm/weblog     +1 650-873-7841

Technical editing and writing, programming, and web development
_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: pointer to some PL-generated KIF?

by Hans Chalupsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can try the aircraft and business KBs that are in the top-level
`kbs' directory of the PowerLoom distribution.

Hans

>>>>> Rich Morin <rdm@...> writes:

> I'm wondering if anyone can point me to a fairly substantial
> body of PL-generated KIF.  I'd like to use it to check out my
> parser.

> -r
> --
> http://www.cfcl.com/rdm            Rich Morin
> http://www.cfcl.com/rdm/resume     rdm@...
> http://www.cfcl.com/rdm/weblog     +1 650-873-7841

> Technical editing and writing, programming, and web development
> _______________________________________________
> powerloom-forum mailing list
> powerloom-forum@...
> http://mailman.isi.edu/mailman/listinfo/powerloom-forum
_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: pointer to some PL-generated KIF?

by Thomas Russ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 24, 2008, at 10:14 AM, Hans Chalupsky wrote:

> You can try the aircraft and business KBs that are in the top-level
> `kbs' directory of the PowerLoom distribution.

And there are also some seismology-related KBs that can be found
on our web site at

    <http://www.isi.edu/isd/LOOM/PowerLoom/download.html#KB>


>
>>>>>> Rich Morin <rdm@...> writes:
>
>> I'm wondering if anyone can point me to a fairly substantial
>> body of PL-generated KIF.  I'd like to use it to check out my
>> parser.
>
>> -r
>> --
>> http://www.cfcl.com/rdm            Rich Morin
>> http://www.cfcl.com/rdm/resume     rdm@...
>> http://www.cfcl.com/rdm/weblog     +1 650-873-7841
>
>> Technical editing and writing, programming, and web development
>> _______________________________________________
>> powerloom-forum mailing list
>> powerloom-forum@...
>> http://mailman.isi.edu/mailman/listinfo/powerloom-forum
> _______________________________________________
> powerloom-forum mailing list
> powerloom-forum@...
> http://mailman.isi.edu/mailman/listinfo/powerloom-forum

_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum
LightInTheBox - Buy quality products at wholesale price