Hi Krasimir,
I am sorry to ask again, but do you have have any idea why my search is
not working as desired? And did may Java file helped you?
I am not able to use my programmed search engine if my created relations
are not recognised by the search.
Thank you
Björn
Krasimir Angelov schrieb:
Hi Bjorn,
Could you send us an example code that you are using for querying? I would
like to try it here to see what happens.
Regards,
Krasimir
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, November 13, 2006 8:26 PM
To: Krasimir Angelov; [email protected]
Subject: Re: [KIM-discussion] Problems with specific grammar rules to extend
thekb
Hi Krasimir,
I am sorry having another KIM problem I cannot solve by myself.
As you said I plugged my relation grammars into GATE after the Instance
Generator and added the annotated relation triples to the sesame kb.
This all works fine and my annotated relations appear in the file
new-temp-triples.nt
E.g. a automatically generated relation in the file is
<http://www.ontotext.com/kim/2005/04/wkb#SfProject.SFx_R.34701>
<http://bjb.com/openSource.owl#hasTopic>
<http://www.ontotext.com/kim/2005/04/wkb#Topic.Email_R.34705> .
while the domain is an instance of the class SfProject in my created
Ontology which extends the Proton Ontology (the Taxonomy is
...->protont:product -> myonto:SoftwareProduct -> myonto:SfProject)
Now I am having the problem that I cannot find this relation using a
Semantic Query in my Application. I am using "Product" as the Domain URI
and "Topic" as Range URI, but the search does not return any result.
But when searching for the Entity 'SFX' in the WebUI, the relation
hasTopic is recognized (see attached Jpeg). I also changed the Domain
URI of my search to SfProject, but this does not work either.
But my Search Query DOES return results if the domain (or range) is an
predefined instance of the knowledge base, e.g. "Gate" as a domain is an
instance of the Proton "Product" class.
The corresponding entry for the automatically generated relation is:
<http://www.ontotext.com/kim/2005/04/wkb#Product_T.2>
<http://bjb.com/openSource.owl#hasTopic>
<http://www.ontotext.com/kim/2005/04/wkb#Topic.Information%20_R.34693> .
Is a Semantic Query restricted to predefined (trusted) Entities only???
B.t.w: An undeclared exception is thrown using the 'getEntities()'
method of the QueryAPI and accessing the EntityQueryResult. Only the
'getDocuments()' Method works in my application.
The Exception is caused by: java.lang.ClassNotFoundException:
com.ontotext.kim.util.ColumnFactoryImpl (no security manager: RMI class
loader disabled)
Do I have to change settings for my SecurityManager or anything else?
My KIM Server Version is 1.6.14.
Thank you very much in advance
Björn
Krasimir Angelov schrieb:
Hi Björn,
You can plug your relation grammars into the GATE application after the
Instance Generator processing resource. That way all extra annotations
will
be preserved. If you want you can use the SemanticRepositoryAPI to store
the
extracted information in Sesame. Since after the Instance Generator
processing all named entities will have unique URIs associated you just
have
to store an extra triple for each extracted relation.
Regards,
Krasimir
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 05, 2006 6:36 PM
To: Krasimir Angelov
Cc: [email protected]
Subject: Re: [KIM-discussion] Problems with specific grammar rules to
extend
thekb
Hi Krasimir,
thank you for your fast answer. Now KIM works nearly perfect, but I also
want to add some relation grammers like 'OpenSourceProject is developed
by Person'. Is this also a possible KIM extension?
And are there any documents which describe the KIM IE components like
the instance generator, KIMGazetteer or KIMOrthomatcher in detail, e.g.
documentations or publications I can refer to (I am currently writing a
bachelor thesis concerned among other things with the evaluation of the
KIM application)?
Björn
Krasimir Angelov schrieb:
Hi Bjorn,
You have to use annotations of type Object instead of type
OpenSourceProject. The instance generator recognizes only a limited set
of
annotation types and all unrecognized annotations are removed.
Krasimir
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bjorn Bohmer
Sent: Wednesday, October 04, 2006 5:05 PM
To: [email protected]
Subject: [KIM-discussion] Problems with specific grammar rules to extend
thekb
Hello everyone,
I have some problems to automatically extend the KIM Knowledge Base.
But perhaps I start to describe what I want to do and what I have done
so far:
I am creating an client application accessing the KIM Api
to achieve automatic semantic annotation for a specific domain.
For example I try to identify open source projects on web-sites like
sourceforge.net etc.
My progress so far:
I extended the PROTON ontology with some of my domain specific classes
(e.g. OpenSourceProject as a subclass of protont/Project).
I also extended the Knowledge Base with some pre-defined Entities (e.g.
Eclipse with some aliases) from a trusted source, until here the KIM
annotation process works fine.
Now I want my application to find new (OpenSourceProject) instances
automatically to extend the KIM knowledge base. For testing purposes I
created some dummy JAPE rules in a new *.jape file and added this to the
default main.jape file in my current context.
Running the KIM Client PR in GATE without the Instance Generator my
domain specific annotations (e.g. OpenSourceProject) are correctly shown
in the 'Annotation Sets' display in addition to the other annotations
(like the internal annotations Lookup, split, unknown etc.). My JAPE
rules also work with default ANNIE processing resources.
But I am having problems running the KIM client PR with the Instance
Generator (my intention is to put my new detected annotations in the
new-temp-triples.nt file). When running this PR in GATE the internal
annotations disappear (which I think is OK) BUT ALSO my newly created
ones disappear. As a consequence I have no desired entries in the *.nt
file (Only 'default' entries like Organisation instances).
I do not understand this behaviour (of the Instance Generator). As it is
mentioned in the KIM manual section 'Extending/Changing the Information
Extraction Module(s)' I can edit the grammars for specific recognition
(but I do not understand why this is not really recommended to reuse the
provided grammar and add specific ones).
I also tried to create a brand new IE Module. First I analysed the KIM
'IE-no-keywords.gapp' file to identify the KIM 'Conditional Corpus
Pipeline' components. But when I tried to rebuild it I had problems
initialzing some KIM specific Processing Resources in GATE (e.g. a
ClassCastException occured when I tried to create a KIM Gazetteer). So I
also do not understand how to build a brand new IE Module for KIM.
Did I missed something to extend the kb? Thanks in advance!
Björn
_______________________________________________
NOTE: Please REPLY TO ALL to ensure that your reply reaches all members
of
this mailing list.
KIM-discussion mailing list
[email protected]
http://ontotext.com/mailman/listinfo/kim-discussion_ontotext.com
package de.bjb.annotation.tools;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import com.ontotext.kim.client.KIMException;
import com.ontotext.kim.client.KIMService;
import com.ontotext.kim.client.corpora.KIMDocument;
import com.ontotext.kim.client.index.IndexAndPersistAPI;
import com.ontotext.kim.client.index.IndexException;
import com.ontotext.kim.client.persist.PersistException;
import com.ontotext.kim.client.query.DocumentQueryResult;
import com.ontotext.kim.client.query.EntityQueryResult;
import com.ontotext.kim.client.query.QueryAPI;
import com.ontotext.kim.client.query.SemanticQuery;
import com.ontotext.kim.client.query.SemanticQueryImpl;
import com.ontotext.kim.client.semanticrepository.SemanticRepositoryAPI;
import de.bjb.annotation.formbeans.SearchForm;
import de.bjb.annotation.utils.SessionBean;
public class SearchEngine {
private static final Log log = LogFactory.getLog(SearchEngine.class);
private SessionBean sessionBean;
private ActionForm form;
public static final String INDEX_PERSIST_URL = "lucene:/C://kim-platform//context//open-source//populated//index-and-store";
private QueryAPI queryApi;
private SemanticRepositoryAPI sesameApi;
private IndexAndPersistAPI luceneApi;
public SearchEngine(SessionBean sessionBean, ActionForm form) {
this.sessionBean = sessionBean;
this.form = form;
}
public List execute() throws RemoteException {
// Get the ActionForm which has the request params from the html form
SearchForm params = (SearchForm) this.form;
// Get KIM Components
KIMService service = this.sessionBean.getKIMService();
this.queryApi = service.getQueryAPI();
this.sesameApi = service.getSemanticRepositoryAPI();
this.luceneApi = service.getIndexAndPersistAPI(INDEX_PERSIST_URL);
// Check for Keyword Search
if (params.getKeyword() != null && params.getKeyword().length() > 1) {
ArrayList keywordresult = new ArrayList();
try {
log.info("Starting KeywordSearch");
StringBuffer filter = new StringBuffer("");
filter.append(" (body:( " + params.getKeyword() + " ))");
List ids = this.luceneApi.getDocsIds(filter.toString());
Iterator i = ids.iterator();
while (i.hasNext()) {
KIMDocument doc = this.luceneApi.loadDoc(i.next());
keywordresult.add(doc);
}
} catch (IndexException ie) {
log.warn("IndexException in Keywordsearch", ie);
} catch (PersistException pe) {
log.warn("PersistException in Keywordsearch", pe);
}
return keywordresult;
}
// Semantic Search was chosen in Web-Frontend
List result = new ArrayList();
// Get the String inserted into the Domain text input field
String domainString = params.getDomain();
log.debug("Domain = " + domainString);
// Get the String inserted into the Range text input field
String rangeString = params.getRange();
log.debug("Range = " + rangeString);
// Get Domain Class from repository
String productUri = sesameApi.getURIFromLocalName("Product").getURI();
log.debug("ProjectUri = " + productUri);
// Get Range Class from repository
String topicUri = sesameApi.getURIFromLocalName("Topic").getURI();
log.debug("TopicUri = " + topicUri);
// Get Relation Property from repository
String relationUri = sesameApi.getURIFromLocalName("hasTopic").getURI();
log.debug("RelationUri = " + relationUri);
String domainVar = "DOMAIN";
String rangeVar = "RANGE";
SemanticQuery query = new SemanticQueryImpl();
try {
// Set Variables and Classes for vars
query.addRequestedVar(domainVar);
query.addRequestedVar(rangeVar);
query.setClass(domainVar, productUri);
query.setClass(rangeVar, topicUri);
// Set Restrictions
query.addNameRestriction(domainVar,
SemanticQuery.COMPARE_STYLE_CONTAINS, domainString);
query.addNameRestriction(rangeVar,
SemanticQuery.COMPARE_STYLE_CONTAINS, rangeString);
query.addPatternRestriction(domainVar, relationUri, rangeVar);
} catch (KIMException e) {
log.error("Error creating query.", e);
}
List doclist = new ArrayList();
List entityList = new ArrayList();
try {
query.setReturnLabels(false);
// Get documents for query
doclist = getDocuments(query);
log.debug("#Docs = " + doclist.size());
/**
* Get Entities !! GetEntities throws Exception, so it is not used
* at the moments. !!!*
*/
// if(System.getSecurityManager() == null) {
// System.setSecurityManager(new RMISecurityManager());
// }
// entityList = getEntities(query);
} catch (Exception ex) {
log.error("Unknown error", ex);
}
result.add(doclist);
// result.add(entityList);
return doclist;
}
private List getDocuments(SemanticQuery q) throws RemoteException {
List result = new ArrayList();
DocumentQueryResult docs = queryApi.getDocuments(q, INDEX_PERSIST_URL,
INDEX_PERSIST_URL);
while (docs.hasNext()) {
KIMDocument doc = docs.nextDocument();
result.add(doc);
log.debug(doc.getName());
}
return result;
}
private List getEntities(SemanticQuery q) throws RemoteException {
List result = new ArrayList();
q.setReturnLabels(true);
EntityQueryResult entities = queryApi.getEntities(q, 100,
QueryAPI.SEMKW_EXECUTION_MODE_DEFAULT);
try {
while (entities.hasNext()) {
log.debug("Size = " + entities.size());
//Here the Exception is trown!!!
Object o = entities.next();
result.add(entities.nextEntityList());
}
} catch (KIMException e) {
log.error("KIMException occured", e);
}
return result;
}
}
_______________________________________________
NOTE: Please REPLY TO ALL to ensure that your reply reaches all members of this
mailing list.
KIM-discussion mailing list
[email protected]
http://ontotext.com/mailman/listinfo/kim-discussion_ontotext.com