jeudi 12 juillet 2012

Trying FRED, a tool for producing RDF/OWL ontologies from natural language sentences


FRED - http://wit.istc.cnr.it/stlab-tools/fred - A tool for automatically producing RDF/OWL ontologies and linked data from natural language sentences, currently limited to English.
FRED is based on C&C [1] and Boxer [2], a NLP tool that transforms natural language text into a logical form compliant to Discourse Representation Theory. We process Boxer output and apply a set of heuristics and semantic transformations in order to obtain RDF designed for the Semantic Web. In this process, we emphasize the relation to linguistic frames, supporting FrameNet and VerbNet vocabularies, and to ontology design patterns.

So I tried first some examples from ATTEMPTO ACE 6.6 in a Nutshell :
A customer inserts a card and the machine checks the code.
Not bad ! FRED uses this class and predicates :
respectively for the sentence, the grammatical subject, and the direct complement.
NOTE: The Options: "FrameNet roles NER Tìpalo WSD" do not have tooltips, so it's not easy to know what they mean.

A customer inserts a VisaCard or inserts a MasterCard, and inserts a code.
The disjunction (or) is not reflected at all in the output. Neither is the negation correctly represented:
It is false that a customer inserts a card.

Now I'll try an example of mine that works with EulerGUI:
If a user U has-as-friend a person X, and has-as-friend a person Y, and X is not Y,
and X has-as-friend Z, and Y has-as-friend Z, and Z is not U
then Z is-a-proposed-friend-for U.
It's clear that the if-then structure is not understood. Even a simple sentence like this is wrong :
If the code is valid then the ATM accepts the card.
FRED tries to be smart, and "thinks" that the ATM is a foaf:Organisation !

Example with ACE Controled Natural Language => OWL => N3 rules


Example with ACE Controled Natural Language => OWL => N3 rules

ATTEMPTO ACE is a Controled Natural Language, that is, a formal language but looking like normal english. It is usable as a modeling and specification language for EulerGUI framework.
Run APE in command line :
% ape.exe -uri http://eulergui.sf.net/contact.owl -ulexfile foaf-lexicon.pl -text 'If P is a person that has-homepage something and has-current-project something then P is an n:interesting-contact .' -solo owlxml > interesting-contact2.owl
Run EulerGUI from command line, reading the OWL file just generated :
eg interesting-contact2.owl htpp://jmvanel.free.fr/jmv.rdf
jmv.rdf is my FOAF profile on the Internet.

The translation of OWL into N3 is :
@prefix ns2: <http://eulergui.sf.net/contact.owl#>.

{ ?VAR <http://xmlns.com/foaf/0.1/currentProject> ?t0.
  ?VAR <http://xmlns.com/foaf/0.1/homepage> ?t2.
  ?VAR a <http://xmlns.com/foaf/0.1/Person>
} => {
  ?VAR a ns2:interesting-contact}.

Now click on the button to launch Drools engine. Since the URI <htpp://jmvanel.free.fr/jmv.rdf#me> ( that's me ) has a foaf:currentProjet and a foaf:homepage , it is inferred that he is an interesting-contact . To confirm this, one can either use the user Knowledge Base display in tools to see the whole KB. Or one can use the N3 shell to ask this query (just paste it with Ctrl-V) :
?X a ns2:interesting-contact .
The answer appears at once :
<http://jmvanel.free.fr/jmv.rdf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://eulergui.sf.net/contact.owl#interesting-contact> .

Under the hood
There is a local lexicon file for ATTEMPTO APE : foaf-lexicon.pl , that tells how to verbalize the foaf concepts in english :
cat foaf-lexicon.pl 

tv_finsg('has-homepage' ,       iri('http://xmlns.com/foaf/0.1/homepage') ).
tv_infpl('have-homepage' ,      iri('http://xmlns.com/foaf/0.1/homepage') ).
tv_finsg('has-current-project' ,        iri('http://xmlns.com/foaf/0.1/currentProject') ).
tv_infpl('have-current-project' ,       iri('http://xmlns.com/foaf/0.1/currentProject') ).

noun_sg( person,        iri('http://xmlns.com/foaf/0.1/Person'), neutr) .
noun_pl( persons,       iri('http://xmlns.com/foaf/0.1/Person'), neutr) .

How to run the demonstration
  1. install ATTEMPTO APE, see http://attempto.ifi.uzh.ch/site/downloads/
  2. download foaf-lexicon.pl from the link
  3. download EulerGUI , preferably the latest snapshot from http://sourceforge.net/projects/eulergui/files/eulergui/1.11/ ; that is an executable (Java) jarEulerGUI Manual is available from help menu
  4. run commands as above

Wellcome to Déductions sofware blog !

Déductions sofware is a service company dedicated to help you to build software that is more flexible, rigourous, and less costly .


To do so, we leverage on a set of collaborating Open Source tools :

  • the Semantic Web technological stack
  • inference (rule) engines like Drools
  • controled (formal) English (ATTEMPTO), to express the logic and business expertiseThis formalism, human readable, expresses both the business rules, and the structuration into classes and properties.