Hi Alavaro,
    the count parameter limits the number of related entities to be returned as results.
Regarding the error, could you please check that listEntities contains URIs represented in String?
Also, in case the problem persists - please tell us the exact version of the KIM Platform that you are using.
all the best
borislav

Alvaro Hernandez wrote:


Note: forwarded message attached.


Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.


Subject:
Method getRelatedEntities (with the attach)
From:
Alvaro Hernandez <[EMAIL PROTECTED]>
Date:
Wed, 8 Aug 2007 05:33:56 -0700 (PDT)
To:
[EMAIL PROTECTED]
To:
[EMAIL PROTECTED]

Hi people,
 
I have a problem using the method getRelatedEntities, I attached the source.
 
   List relEntities = apiEntity.getRelatedEntities(listEntities,1);
 
By the way, what's the meaning of the 'count' (second) parameter ?
 
Error in runtime:
 
     
java.lang.ClassCastException: org.openrdf.model.impl.URIImpl cannot be cast to java.lang.String
at com.ontotext.kim.proton.KIMEntityAPIImpl.getRelatedEntities(KIMEntityAPIImpl.java:525)
at com.ontotext.kim.proton.KIMEntityAPIImpl.getRelatedEntities(KIMEntityAPIImpl.java:500)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
.........
.........
 
Thank you,
Alvaro


Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.

package utiles_kim; import com.ontotext.kim.client.*; import com.ontotext.kim.client.query.*; import com.ontotext.kim.client.model.*; import com.ontotext.kim.client.proton.*;


import java.util.*;

import java.util.Iterator;
import java.lang.String;

public class RelatedEntitiesProof
{
	
    public static final String INDEX_URL = "c:/kim-platform-1.7.12.15/context/default/populated/index-and-store";
    public static final String PERSIST_URL = "lucene:/c:/kim-platform-1.7.12.15/context/default/populated/index-and-store";
    public final static String INDEX_AND_PERSIST_URL = "lucene:/c:/kim-platform-1.7.12.15/context/default/populated/index-and-store";
    private static QueryAPI apiQuery = null;
    private static EntityAPI apiEntity = null;
    
    public static void main(String[] args)
    {
        try
        {
            KIMService serviceKim = GetService.from();
            spit("KIM Server connected.");
            
            // obtain CorporaAPI and SemanticAnnotationAPI components
            apiQuery = serviceKim.getQueryAPI();
            apiEntity = serviceKim.getEntityAPI();

                    // ----------------------------------------------------------------------------------
                    // construct semantic query 1
                    // ----------------------------------------------------------------------------------
                    SemanticQuery seq1 = new SemanticQueryImpl();            
                    seq1.addRequestedVar("CONT");  // add variable PERS of class Person
                    seq1.setClass("CONT", WKBConstants.CLASS_CONTINENT);
                    
                    // ----------------------------------------------------------------------------------
                    // add name and pattern restrictions for seq1
                    // ----------------------------------------------------------------------------------
                    seq1.addNameRestriction("CONT", seq1.COMPARE_STYLE_CONTAINS, "Europe");
                                                     // restrict position to contain 'manager'
                    EntityQueryResult resEntities = apiQuery.getEntities(seq1);
                    spit("[ Entity Result (begin) ]");
                    while (resEntities.hasNext()) {
                      spit(" b- ---------------------------");
                      List listEntities = resEntities.nextEntityList();
                      
                      spit("count list " + listEntities.size());
                      
                      for (int i = 0; i <= listEntities.size(); i += 2) {
                    	  
                    	String uri = String.valueOf(listEntities.get(i));
                    	Entity ent = apiEntity.getEntity(uri);

                    	// Aliases de la entidad
                    	Iterator entIterator = ent.getAliases();
                        //spit("[ Document's Annotations (begin) ]");
                    	while (entIterator.hasNext()) {
                    		String key1 = (String) entIterator.next();
                    		
                            spit(" = GetAliases [" + key1 + "] :");
                              
                        }

                      List relEntities = apiEntity.getRelatedEntities(listEntities,1);
                        
                      }  
      
                    }

        }
                
        catch (Exception x)
        {
            x.printStackTrace();
        }
    }

    public static void spit(Object o)
    {
        System.out.println(o);
    }

}
  

_______________________________________________ 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

No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.484 / Virus Database: 269.11.19/956 - Release Date: 8/16/2007 9:48 AM
_______________________________________________
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

Reply via email to