示例#1
0
 public Set<String> findCandidatesForClass(String classUri) {
   Set<String> listOfPotentialCandidates = new HashSet<String>();
   listOfPotentialCandidates.addAll(
       luceneAnnotator.getDefinedPropertiesWhereClassIsADomain(classUri, forceSuperClasses));
   listOfPotentialCandidates.addAll(
       luceneAnnotator.getDefinedPropertiesWhereClassIsARange(classUri, forceSuperClasses));
   Set<String> filteredList = new HashSet<String>();
   for (String t : listOfPotentialCandidates) {
     if (!isInIgnoreNameSpaceList(t)) {
       filteredList.add(t);
     }
   }
   return filteredList;
 }
示例#2
0
  /**
   * find properties with no domain or range defined and also add some generic elements like label
   * or type
   *
   * @return
   */
  List<OntologyElement> findHangingElements() throws Exception {
    List<OntologyElement> elements = new ArrayList<OntologyElement>();
    Set<String> properties = new HashSet<String>();
    properties.add(RDFS.LABEL.toString());
    properties.add(RDF.TYPE.toString());
    String table = suggestionsHelper.getDatatypePropertiesNoDomain();
    properties.addAll(StringUtil.fromStringToSet(table));

    String thingUri = "http://www.w3.org/2002/07/owl#Thing";
    properties.addAll(
        luceneAnnotator.getDefinedPropertiesWhereClassIsADomain(thingUri, forceSuperClasses));
    properties.addAll(
        luceneAnnotator.getDefinedPropertiesWhereClassIsARange(thingUri, forceSuperClasses));
    elements.addAll(returnPropertyElements(properties));

    logger.info("Adding:" + properties.size() + " hanging properties");

    Set<String> classes = new HashSet<String>();
    classes.add(thingUri);
    elements.addAll(returnClassElements(classes));
    return elements;
  }
示例#3
0
 /**
  * @param property
  * @param text
  * @return
  */
 private List<OntologyElement> findCandidatesForAProperty(PropertyElement property, String text)
     throws Exception {
   // Set<String> allSuggestions = new HashSet<String>();
   String uri = ((SerializableURI) property.getData()).toString();
   logger.debug("Finding candidates for property:" + property.getData().toString());
   // all elements
   List<OntologyElement> elements = new ArrayList<OntologyElement>();
   // feed classes: these are used to find more suggestions but they are also
   // added to the list!
   Set<String> feedClasses = new HashSet<String>();
   Set<String> properties = new HashSet<String>();
   Set<String> allClasses = new HashSet<String>();
   Set<String> rangeClasses = luceneAnnotator.findPropertyRange(uri);
   feedClasses.addAll(rangeClasses);
   logger.debug("getRangeClassesForProperty:" + uri + " found " + rangeClasses.size());
   Set<String> domainClasses = luceneAnnotator.findPropertyDomain(uri);
   feedClasses.addAll(domainClasses);
   logger.debug("getDomainClassesForProperty:" + uri + " found " + domainClasses.size());
   if (feedClasses == null || feedClasses.size() <= 1) {
     // find top classes
     logger.debug("Number of feed classes is 0....forceSuggestions=" + forceSuggestions);
     if (new Boolean(forceSuggestions).booleanValue() == true) {
       feedClasses.addAll(luceneAnnotator.findClassURIs());
     }
   }
   // a onda za te classes nadji properties where class is a domain/range
   for (String classUri : feedClasses) {
     properties.addAll(
         luceneAnnotator.getDefinedPropertiesWhereClassIsADomain(classUri, forceSuperClasses));
     properties.addAll(
         luceneAnnotator.getDefinedPropertiesWhereClassIsARange(classUri, forceSuperClasses));
   }
   //
   if (new Boolean(forceSuggestions).booleanValue() == true) {
     logger.info(
         "cheating!!!!!!!!!!!!!!!!!!!!!!!!!!! here you should not get ALL properties but only relevant ones");
     Set<String> datatypePropertiesList = luceneAnnotator.findDatatypePropertyURIs();
     Set<String> objectPropertiesList = luceneAnnotator.findObjectPropertyURIs();
     Set<String> rdfPropertiesList = luceneAnnotator.findRDFPropertyURIs(null);
     properties.addAll(datatypePropertiesList);
     properties.addAll(objectPropertiesList);
     properties.addAll(rdfPropertiesList);
   }
   Set<String> filteredProperties = new HashSet<String>();
   for (String t : properties) {
     if (!isInIgnoreNameSpaceList(t)) {
       filteredProperties.add(t);
     }
   }
   // add datatype properties which do not have domain defined: mb endDate
   // beginDate
   // String table = getSparqlUtils().getDatatypePropertiesNoDomain();
   // properties.addAll(gate.freya.util.StringUtil.fromStringToSet(table));
   elements.addAll(returnPropertyElements(filteredProperties));
   for (String classUri : feedClasses) {
     allClasses.addAll(
         luceneAnnotator.getNeighbouringClassesWhereGivenClassIsADomain(
             classUri, forceSuperClasses));
     allClasses.addAll(
         luceneAnnotator.getNeighbouringClassesWhereGivenClassIsARange(
             classUri, forceSuperClasses));
   }
   Set<String> filteredFeedClasses = new HashSet<String>();
   for (String t : feedClasses) {
     if (!isInIgnoreNameSpaceList(t)) {
       filteredFeedClasses.add(t);
     }
   }
   allClasses.addAll(filteredFeedClasses);
   elements.addAll(returnClassElements(allClasses));
   return elements;
 }