Hi Philip,
Hi All,
here three questions in order of importance for me (thanks so much for any 
your advice):


1)  "SongTitle" is a sub-class of Entity (which should be linked to 
ontology....) in in.space.owl; and "1973", "You're beautiful", etc.  are 
instances of this class in in.space.nt
My program using KIM API annotates only  "1973" (not "You're beautiful" or 
any other instance of any other my class) as follows:

-- KIMAnnotationImpl: id=54; type=Time; features={rule1=TempYear3, class=http:
//proton.semanticweb.org/2006/05/protonu#CalendarYear, originalName=1973, 
rule2=YearOnlyFinal, inst=http://www.ontotext.com/kim/2006/05/wkb#Song_1973, 
kind=date}; start=0; end=4

so my program annotates "1973" incorrectly, because Song_1973 is an instance 
of SongTitle, not of CalendarYear!!

I've tried to add a jape rule gaz_song.jape (as your advice, adding it also 
in main.jape), but nothing has changed. Please check if it is correct not 
syntactically, but logically (semantically).


2) If I wold like to get both the instance (with its features) of 
CalendarYear and the instace (with its features) of SongTitle when I annotate 
the word "1973", do I have to use KIM API "Search for Entities"? Or I have to 
modify IE pipeline. Please give me some advice...  
    

3) Now that I've created my classes "SongTitle", "Singer", "MusicGenre", to 
populate KIM KB with instances of these classes the only way is manually? Does 
toolPopulate.cmd recognize some instances if I pass them in a structured or 
semi-structured way? 


The first two questions are more important. 
Greetings,
Valentina  
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(); 
                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."); 
        
        
        URL url= new URL ("file://localhost/C:\\testo.txt");

       
        KIMDocument kdoc3= apiCorpora.createDocument(url, "UTF-8");
      
   
        KIMDocument kdoc4= null;


        
        kdoc4= apiSemAnn.execute(kdoc3);
        System.out.println("Testo annotato.");
        

            
        
        // Ispeziona le caratteristiche del documento (Document's Features)
        testDF(kdoc4);
        
        // Ispeziona le annotazioni del documento (Document's Annotations)
        testDA(kdoc4);
       
        // Ispeziona tutte le annotazioni (All Annotations)
            testAA(kdoc4);
        
            // Ispeziona le annotazioni di un certo tipo (Annotation of Certain 
Type(s))
       testAT(kdoc4);
            
        // Ispeziona le caratteristiche delle annotazioni (Annotation's 
Features)
       //testAF(kdoc4);
        

        
        // Ispeziona le caratteristiche di classi e istanze (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("Singer"); 
                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 [ Singer 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***"); 
        }
        
        
        
}
1973 James Blunt
La solitudine Laura Pausini 
Meravigliosa creatura Gianna Nannini
<?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/2006/05/protons#'>
        <!ENTITY ptop  'http://proton.semanticweb.org/2006/05/protont#'>    
        <!ENTITY protonkm 'http://proton.semanticweb.org/2006/05/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:AnnotationProperty rdf:about="http://www.w3.org/2002/07/owl#versionInfo"/>

    <owl:Ontology rdf:about="">
        <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>InSpac</rdfs:label>
        <rdfs:comment>InSpace Ontolog</rdfs:comment>
        <owl:imports rdf:resource="http://proton.semanticweb.org/2006/05/protonkm"/>
        <owl:versionInfo>"0.11"</owl:versionInfo>
    </owl:Ontology>

    <owl:Class rdf:ID="SongTitle">
        <rdfs:label>SongTitle</rdfs:label>
        <rdfs:comment>
        A short musical composition with words.
        </rdfs:comment>
        <rdfs:subClassOf rdf:resource="&protonkm;Entity"/>
    </owl:Class>

    <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="MusicGenre">
        <rdfs:label>MusicGenre</rdfs:label>
        <rdfs:comment>
        An expressive style of music
        </rdfs:comment>
        <rdfs:subClassOf rdf:resource="&protonkm;Entity"/>
    </owl:Class>

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

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

    </rdf:RDF>

Attachment: in.space.nt
Description: Binary data

Attachment: gaz_song.jape
Description: Binary data

_______________________________________________
Kim-discussion mailing list
Kim-discussion@ontotext.com
http://ontotext.com/mailman/listinfo/kim-discussion

Reply via email to