Hi,
I missing three steps to finish my studies about KIM, so please help me! ;-)
The following is the first.

I'm trying to extend the KIM ontology, to annotate documents or text 
according to the new classes and instances that I introduce. 

1) I’ve attached my files .owl and .nt… please check them.

2) I have put “song2009.owl” in \kb\owl\ folder, and “song2009.nt” in \kb\ 
folder.

3) I have modified the “sesame.inmem.conf” with the following:
<param name="imports" value=
                                "kb/owl/owl.rdfs;
                                 kb/owl/protons.owl;
                                 kb/owl/protont.owl;
                                 kb/owl/protonu.owl;
                         kb/owl/song2009.owl;
                         kb/song2009.nt;
                                 kb/visibility.nt;
                                 
                                 kb/wkbx.nt;"/>
                        <param name="defaultNS" value=
                                "http://www.w3.org/2002/07/owl#;
                                http://proton.semanticweb.org/2006/05/protons#;
                                http://proton.semanticweb.org/2006/05/protont#;
                                http://proton.semanticweb.org/2006/05/protonu#;
                        http://song2009.owl#;
                                http://www.ontotext.com/kim/2006/04/wkb#;
                                http://www.ontotext.com/kim/2006/04/wkb#;
                                http://www.ontotext.com/kim/2006/04/wkb#;"/>  
                        <param name="concurentInference" value="true"/>

and I’ve deleted the line kb/wkb.net, because when I used “startKIM.bat” it 
generated exceptions (and I don’t know why).

4) I have added at the end of “\kb\visibility.nt” these lines:
<http://song2009.owl#Song> <http://www.ontotext.
com/kim/2006/05/kimso#visibilityLevel1> "" .
<http://song2009.owl#Singer> <http://www.ontotext.
com/kim/2006/05/kimso#visibilityLevel1> "" .
<http://song2009.owl#Genre> <http://www.ontotext.
com/kim/2006/05/kimso#visibilityLevel1> "" .
<http://song2009.owl#Composer> <http://www.ontotext.
com/kim/2006/05/kimso#visibilityLevel1> "" .
<http://song2009.owl#Band> <http://www.ontotext.
com/kim/2006/05/kimso#visibilityLevel1> "" .

which have a corresponding label in song2009.owl.

5) Finally I restarted the servers, but my program DocTest.java using KIM API 
about semantic annotation (that I have attached and tested successfully with 
your example) don’t annotate my text, don’t find my istance.

What did I wrong in this procedure?
Thanks so much for your patience,
Valentina
<!-- song2009.owl -->
    
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE owl [ 
        <!ENTITY rdf  'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
        <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
        <!ENTITY owl  'http://www.w3.org/2002/07/owl#'>
        <!ENTITY xsd  'http://www.w3.org/2001/XMLSchema#'>
        <!ENTITY psys  'http://proton.semanticweb.org/2005/04/protons#'>
        <!ENTITY ptop  'http://proton.semanticweb.org/2005/04/protont#'>    
        <!ENTITY protonkm 'http://proton.semanticweb.org/2005/04/protonkm#'>
    ]>
    <rdf:RDF 
        xmlns:owl="&owl;"
        xmlns:rdf="&rdf;"
        xmlns:rdfs="&rdfs;"
        xmlns:psys="&psys;"
        xmlns:ptop="&ptop;"
        xmlns:protonkm="&protonkm;"
        xmlns="http://in.space#";
        xml:base="http://in.space#";>   


    <owl:AnnotationProperty rdf:about="http://www.w3.org/2000/01/rdf-schema#comment"/>
    <owl:AnnotationProperty rdf:about="http://www.w3.org/2000/01/rdf-schema#label"/>


    <owl:Ontology rdf:about="">
        <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>song2009</rdfs:label>
        <rdfs:comment>Song Ontology</rdfs:comment>
        <owl:imports rdf:resource="http://proton.semanticweb.org/2005/04/protonkm"/>
    </owl:Ontology>


    <owl:Class rdf:ID="Song">
        <rdfs:label>Song</rdfs:label>
        <rdfs:comment>
        a short musical composition with words
        </rdfs:comment>
        <rdfs:subClassOf rdf:resource="&protonkm;Object"/>
    </owl:Class>

    <owl:ObjectProperty rdf:about="#createdBy" rdfs:label="sungBy">
        <rdfs:domain rdf:resource="#Song"/>
        <rdfs:range rdf:resource="&ptop;Agent""/>
    </owl:ObjectProperty>


    <owl:Class rdf:ID="Singer">
        <rdfs:label>Singer</rdfs:label>
        <rdfs:comment>
        a person who sings
        </rdfs:comment>
        <rdfs:subClassOf rdf:resource="&protonkm;Person"/>
    </owl:Class>


    <owl:Class rdf:ID="Composer">
        <rdfs:label>Composer</rdfs:label>
        <rdfs:comment>
        someone who composes music as a profession
        </rdfs:comment>
        <rdfs:subClassOf rdf:resource="&protonkm;Person"/>
    </owl:Class>


    <owl:Class rdf:ID="Band">
        <rdfs:label>Band</rdfs:label>
        <rdfs:comment>
        a group of people who sing
        </rdfs:comment>
        <rdfs:subClassOf rdf:resource="&protonkm;Group"/>
    </owl:Class>


    <owl:Class rdf:ID="Genre">
        <rdfs:label>Genre</rdfs:label>
        <rdfs:comment>
        an expressive style of music
        </rdfs:comment>
        <rdfs:subClassOf rdf:resource="&protonkm;GeneralTerm"/>
    </owl:Class>



    </rdf:RDF>

Attachment: song2009.nt
Description: Binary data

import com.ontotext.kim.client.KIMService;
import com.ontotext.kim.client.GetService;
import com.ontotext.kim.client.corpora.CorporaAPI;
import com.ontotext.kim.client.documentrepository.DocumentRepositoryAPI;
import com.ontotext.kim.client.semanticannotation.SemanticAnnotationAPI;
import com.ontotext.kim.client.query.QueryAPI;
import com.ontotext.kim.client.semanticrepository.SemanticRepositoryAPI;
import com.ontotext.kim.client.coredb.CoreDbAPI;

import com.ontotext.kim.client.corpora.KIMDocument;
import com.ontotext.kim.client.corpora.KIMFeatureMap;
import com.ontotext.kim.client.corpora.KIMFeatureMapImpl;
import com.ontotext.kim.client.corpora.KIMAnnotation;
import com.ontotext.kim.client.corpora.KIMAnnotationSet;
import com.ontotext.kim.client.corpora.KIMCorporaException;
import com.ontotext.kim.client.model.FeatureConstants;

import java.net.URL;
import java.util.Iterator;
import java.util.Set;
import java.util.HashSet;


public class DocTest {

        public static final String RMI_HOST= "localhost"; 
        public static final int RMI_PORT= 1099;
        
        public static void main(String[] args) {
                
        try {   
                // connessione al KIMservice
                KIMService serviceKim= GetService.from(RMI_HOST, RMI_PORT); 
            System.out.println("KIM Server connesso."); 
                
            // otteniamo componenti CorporaAPI e SemanticAnnotationAPI
            CorporaAPI apiCorpora= serviceKim.getCorporaAPI(); 
        System.out.println("CorporaAPI ottenuto con successo."); 
        
        SemanticAnnotationAPI apiSemAnn = 
serviceKim.getSemanticAnnotationAPI(); 
        System.out.println("SemanticAnnotationAPI ottenuto con successo."); 

       
        String  content= "James Blunt, Pop, 1973, Rock";


        KIMDocument kdoc3= apiCorpora.createDocument(content, "UTF-8");
        KIMDocument kdoc4= null;
        
       
        kdoc4= apiSemAnn.execute(kdoc3);
        System.out.println("Testo annotato.");

        
        // (Document's Features)
        testDF(kdoc4);
        
        // (Document's Annotations)
        testDA(kdoc4);
       
        //  (All Annotations)
            testAA(kdoc4);
        
          // (Annotation of Certain Type(s))
        testAT(kdoc4);
            
        //  (Annotation's Features)
        testAF(kdoc1);
        

        // (Class and Inst Features )
        testCIF(kdoc4);
        
        } catch (Exception e) {e.printStackTrace();}
        }
        
        
        
        public static void testDF(KIMDocument kdoc) throws KIMCorporaException {
        KIMFeatureMap kimFeatures= kdoc.getFeatures(); 
        
        if(kimFeatures != null){ 
                Iterator iterator= kimFeatures.keySet().iterator(); 
                
                System.out.println("\n");
                System.out.println("--> Caratteristiche del documento 
***begin***"); 
                while(iterator.hasNext()) {
                        Object key= iterator.next(); 
                        System.out.println("[key: " + key + "] [feature: " + 
kimFeatures.get(key) + "]"); 
                } 
                System.out.println("--> Caratteristiche del documento 
***end***"); 
        } 
        }
        
        
        public static void testDA(KIMDocument kdoc) throws KIMCorporaException {
                KIMAnnotationSet kimASet= kdoc.getAnnotations(); 
        Iterator annIterator= kimASet.iterator(); 
        
        System.out.println("\n");
        System.out.println("--> Annotazioni del documento ***begin***"); 
        while(annIterator.hasNext()) { 
                System.out.print(annIterator.next()); 
        } 
        System.out.println("--> Annotazioni del documento ***end***"); 
        }
        
        
        
        public static void testAA(KIMDocument kdoc) throws KIMCorporaException {
                KIMAnnotationSet kimASet= kdoc.getAnnotations(); 
                Set typesSet= kimASet.getAllTypes(); 
                Iterator iterator= typesSet.iterator(); 
        
                // mostra le annotazioni di ogni tipo separatamente
                System.out.println("\n");
                System.out.println("--> Tipi di annotazione del documento 
***begin***"); 
                while(iterator.hasNext()) { 
                      Object key= iterator.next(); 
                      KIMAnnotationSet kimFilteredASet= 
kimASet.get(String.valueOf(key)); 
                      Iterator annIterator= kimFilteredASet.iterator(); 
                      System.out.println(" == Annotazioni di tipo [" + 
String.valueOf(key) + "] :"); 
                      
                      while(annIterator.hasNext()) {
                          System.out.print("   -- " + annIterator.next()); 
                      } 
                } 
                System.out.println("--> Tipi di annotazione del documento 
***end***"); 

        }
        
        
        
        public static void testAT(KIMDocument kdoc) throws KIMCorporaException {
                KIMAnnotationSet kimASet= kdoc.getAnnotations(); 
                HashSet typesNewSet= new HashSet (); 
                typesNewSet.add("Person"); 
                typesNewSet.add("Organization"); 
                
                KIMAnnotationSet kimFilteredASet= kimASet.get(typesNewSet); 
                Iterator annIterator= kimFilteredASet.iterator(); 
                System.out.println("\n");
                System.out.println("--> Filtraggio del documento per tipo di 
annotazione ***begin***"); 
                System.out.println(" == Annotazioni di tipo [ Person e 
Organization ] :"); 
                while(annIterator.hasNext()) { 
                        System.out.print("   -- " + annIterator.next()); 
                } 
                System.out.println("--> Filtraggio del documento per tipo di 
annotazione ***end***"); 
        }
        
        
        public static void testAF(KIMDocument kdoc) throws KIMCorporaException {
                KIMAnnotationSet kimASet= kdoc.getAnnotations(); 
                Iterator annIterator= kimASet.iterator(); 
                
                System.out.println();
                System.out.println("[ Caratteristiche delle annotazioni (begin) 
]"); 
                while(annIterator.hasNext()) { 
                      KIMAnnotation kimAnnotation = (KIMAnnotation) 
annIterator.next(); 
                      System.out.println(" = [ Annotation ] : " + 
kimAnnotation); 
                      KIMFeatureMap kimFeatures = kimAnnotation.getFeatures(); 
                      if(kimFeatures != null) {
                          Iterator iterator= kimFeatures.keySet().iterator(); 
                          System.out.println(" = [ Features ] : "); 
                      
                          while(iterator.hasNext()) {
                              Object key = iterator.next(); 
                              System.out.println(" -- [key: " + key + "] 
[feature: " + kimFeatures.get(key) + "]"); 
                          } 
                      System.out.println(""); 
                    } 
                } 
                System.out.println("[ (end) ]");
        }

        
        
        public static void testCIF(KIMDocument kdoc) throws KIMCorporaException 
{
                KIMAnnotationSet kimASet= kdoc.getAnnotations(); 
                Iterator annIterator= kimASet.iterator(); 
                
                System.out.println();
                System.out.println("--> Caratteristiche specifiche delle 
annotazioni ***begin***"); 
                while(annIterator.hasNext()) { 
                      KIMAnnotation kimAnnotation= (KIMAnnotation) 
annIterator.next(); 
                      System.out.println(" == [ Annotation ] : " + 
kimAnnotation.getId() + "]"); 
                      KIMFeatureMap kimFeatures = kimAnnotation.getFeatures(); 
                      
                      if(kimFeatures != null) {
                          System.out.println("   -- [Name: " + 
kimFeatures.get(FeatureConstants.FEATURE_ORIGINAL_NAME) + "]" +
                                             "[Class: " + 
kimFeatures.get(FeatureConstants.CLASS) + "]" +
                                             "[Instance: " + 
kimFeatures.get(FeatureConstants.INSTANCE) + "]"); 
                      } 
                } 
                System.out.println("--> Caratteristiche specifiche delle 
annotazioni ***end***"); 
        }
        
        
        
}
_______________________________________________
Kim-discussion mailing list
[email protected]
http://ontotext.com/mailman/listinfo/kim-discussion

Reply via email to