Here is the code I wrote to test document addition:
KIMService serviceKim = GetService.from("192.168.11.11");
CorporaAPI apiCorpora = serviceKim.getCorporaAPI();
SemanticAnnotationAPI apiSemAnn =
serviceKim.getSemanticAnnotationAPI();
DocumentRepositoryAPI apiDR =
serviceKim.getDocumentRepositoryAPI();
String uri = "http://www.ontotext.com/kim";
URL url = new URL(uri);
KIMDocument kdocFromUrl = apiCorpora.createDocument(url,
"UTF-8");
kdocFromUrl.putFeature(KIMDocument.DOCUMENT_FEATURE_TITLE,
"Onto");
kdocFromUrl.putFeature(KIMDocument.DOCUMENT_FEATURE_SOURCE,
"Onto Site");
kdocFromUrl.putFeature(KIMDocument.DOCUMENT_FEATURE_AUTHORS,
"Ontotext");
kdocFromUrl.putFeature(KIMDocument.DOCUMENT_FEATURE_URL, uri);
kdocFromUrl.putFeature("LENSID", 2);
KIMDocument kdocFromUrlAnn = apiSemAnn.execute(kdocFromUrl);
apiDR.addDocument(kdocFromUrlAnn);
It gives error at kdocFromUrl.putFeature("LENSID", 2).
Regards,
Naaman Musawwir.
_____
From: Philip Alexiev [mailto:[email protected]]
Sent: Tuesday, November 30, 2010 7:03 PM
To: Naaman Musawwir
Cc: [email protected]
Subject: Re: [Kim-discussion] Help - Document Feature Schema
Could you describe exactly how you are trying to add your custom feature to
the document ? Please also provide the output of the tools (and KIM) you
are using. Also you may set the log level to DEBUG for more verbose output.
In config/log.prop change:
log4j.rootLogger=INFO, aAll, cAll
to
log4j.rootLogger=DEBUG, aAll, cAll
Philip
On 11/30/2010 03:40 PM, Naaman Musawwir wrote:
Hello,
The problem I am facing is while using option 1 where we need to add a
feature LENSID manually into the custom created documents. I fetched feature
schema that also did not include LENSID in the list. What am I missing if
just updating this list is sufficient? I followed the process below but that
gives a nullpointer exception when trying to add LENSID.
We have implemented a GATE plug-in with a custom IE application that is
working fine. That adds NEAR_TOKENS feature automatically in the documents
according tour custom logic. This works fine when we add documents using
populator.
Regards,
Naaman Musawwir.
From: Boyan Kukushev [mailto:[email protected]]
Sent: Tuesday, November 30, 2010 4:53 PM
To: [email protected]
Cc: Naaman Musawwir; 'Philip Alexiev @ Ontotext'
Subject: Re: [Kim-discussion] Help - Document Feature Schema
Hello Naaman,
Adding a custom feature to your documents is actually not a simple task to
do,
especially if you are trying to populate the documents using out populator
tool.
1) If you are using the Java API to annotate and store documents into the
KIM
server, the procedure is as follows:
- update the com.ontotext.kim.KIMConstants.DOCUMENT_FEAT_LIST property
in
kim-home/config/document.repository.properties configuration file, adding
the
name of your custom property to the list of properties
- start the KIM server
- you have to use the following (or similar) code to annotate, add the
custom
property value and store the document into the server:
// retrieve all necessary server APIs
KIMService service = GetService.from("localhost", 1099);
DocumentRepositoryAPI dr = service.getDocumentRepositoryAPI();
SemanticAnnotationAPI sa = service.getSemanticAnnotationAPI();
CorporaAPI ca = service.getCorporaAPI();
// use corpora API to retrieve object of KIMDocument type
// by invoking the most suitable method
KIMDocument doc = ca.createDocument(new URL("someurl"), "UTF-8");
// semantically annotate the content of the document
// read carefully the javadoc to understand what is happening
doc = sa.execute(doc);
// add your feature to the document
// the features can be of any type
// String is recommended
Object myFeatureValue = ...;
doc.putFeature("MYFEATURE", myFeatureValue);
// store the document
dr.addDocument(doc);
For more detail on using KIM server APIs check our documentation at
http://ontotext.com/kim/doc/KimDocs-3.0-EN/DevelopersGuide.html and
http://nmwiki.ontotext.com/kim-javadoc/index.html
2) If you are using our populator tool, all this gets much more complex. As
long as all things that the code above does happen in the populator tool
JVM,
you can't modify any object there. In order to be able to set your custom
property, you have to add another step to the annotation process. That
process is controlled by a special file:
kim-home/context/default/resources/IE.gapp (by default!).
This is the description of our GATE application; in short, GATE is a
platform
for text analysis and similar stuff, developed by our colleagues at the
University of Sheffield . See http://gate.ac.uk for more info. If you are
not
familiar with GATE, I'm afraid it will be much harder to achieve your goal.
With a few words - you have to add a new GATE processing resource to the
GATE
application. That processing resource would actually do the job of setting
your custom property to the document. If you need more information, you can
always ask us, but it is really recommended that you know how to do things
with GATE.
Hope this helps!
Regards,
Boyan Kukushev,
KIM Platform developer, KIM team
On Thu November 25 2010 16:48:30 Naaman Musawwir wrote:
> Attached is the properties file.
>
>
>
> Regards,
>
> Naaman Musawwir.
>
> _____
>
> From: Philip Alexiev @ Ontotext [mailto:[email protected]]
> Sent: Thursday, November 25, 2010 7:07 PM
> To: Naaman Musawwir
> Cc: [email protected]
> Subject: Re: [Kim-discussion] Help - Document Feature Schema
>
>
>
> Hi Naaman
>
>
>
> Adding your custom feature to the list is sufficient. Please send your
> document.repository.properties if you still have problems with that.
>
>
>
> Greetings,
>
> Philip Alexiev
>
> Software Engineer, KIM Team
>
>
>
> On Nov 25, 2010, at 9:57 AM, Naaman Musawwir wrote:
>
>
>
>
>
> Hello,
>
>
>
> I want to add a few custom features to KIM documents. How should I do
that?
> I updated the propertycom.ontotext.kim.KIMConstants.DOCUMENT_FEAT_LIST in
> <KIM_HOME>conf/document.repository.properties but even after that I get
the
> error that
>
>
>
> Features [CUSTOM_FEATURE] are not in the feature schema. Feature schema is
> currently: [SUBJECT, AUTHORS, SOURCE, LANGUAGE, DOCTYPE, KEYENTITIES,
> KEYPHRASES, TIMESTAMP, URL, TITLE]
>
>
>
> What to do more in this regard?
>
>
>
> Regards,
>
> Naaman Musawwir.
>
>
>
> _______________________________________________
> Kim-discussion mailing list
> [email protected]
> http://ontotext.com/mailman/listinfo/kim-discussion
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.872 / Virus Database: 271.1.1/3277 - Release Date: 11/25/10
> 00:34:00
>
>
>
--
Boyan Kukushev
Senior Software Engineer / Java Developer
Ontotext AD @ Sirma Group Corp.
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1170 / Virus Database: 426/3288 - Release Date: 11/29/10
--
Philip Alexiev <mailto:[email protected]>
<[email protected]>
Software Engineer
Ontotext AD
_____
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1170 / Virus Database: 426/3288 - Release Date: 11/29/10
_______________________________________________
Kim-discussion mailing list
[email protected]
http://ontotext.com/mailman/listinfo/kim-discussion