Beispiel #1
0
  /** Sets up the default matching configuration for the ontologies */
  public void defaultConfig() {
    bkSources = new Vector<String>();
    File ontRoot = new File(BK_PATH);
    if (ontRoot.exists()) {
      FileFilter ont =
          new ExtensionFilter(
              "Ontology Files (*.owl, *.rdf, *.rdfs, *.xml)",
              new String[] {".owl", ".rdf", ".rdfs", ".xml"},
              false);
      File[] ontFiles = ontRoot.listFiles(ont);
      for (File f : ontFiles) bkSources.add(f.getName());
      FileFilter lex =
          new ExtensionFilter("Lexicon Files (*.lexicon)", new String[] {".lexicon"}, false);
      File[] lexFiles = ontRoot.listFiles(lex);
      for (File f : lexFiles) bkSources.add(f.getName());
      bkSources.add("WordNet");
    } else {
      System.out.println("WARNING: 'store/knowledge' directory not found!");
    }
    selectedSources = new Vector<String>(bkSources);

    size = SizeCategory.getSizeCategory();
    lang = LanguageSetting.getLanguageSetting();
    languages = new HashSet<String>();
    for (String s : source.getLexicon().getLanguages())
      if (target.getLexicon().getLanguages().contains(s)) languages.add(s);
    if (languages.contains("en") || languages.size() == 0) language = "en";
    else language = languages.iterator().next();
    matchSteps = new Vector<MatchStep>();
    if (lang.equals(LanguageSetting.TRANSLATE)) matchSteps.add(MatchStep.TRANSLATE);
    matchSteps.add(MatchStep.LEXICAL);
    if (lang.equals(LanguageSetting.SINGLE)) matchSteps.add(MatchStep.BK);
    if (!size.equals(SizeCategory.HUGE)) matchSteps.add(MatchStep.WORD);
    matchSteps.add(MatchStep.STRING);
    if (size.equals(SizeCategory.SMALL) || size.equals(SizeCategory.MEDIUM))
      matchSteps.add(MatchStep.STRUCT);
    double sourceRatio =
        (source.dataPropertyCount() + source.objectPropertyCount()) * 1.0 / source.classCount();
    double targetRatio =
        (target.dataPropertyCount() + target.objectPropertyCount()) * 1.0 / target.classCount();
    if (sourceRatio >= 0.05 && targetRatio >= 0.05) matchSteps.add(MatchStep.PROPERTY);
    if (size.equals(SizeCategory.HUGE)) matchSteps.add(MatchStep.OBSOLETE);
    matchSteps.add(MatchStep.SELECT);
    matchSteps.add(MatchStep.REPAIR);
    hierarchic = true;
    wms = WordMatchStrategy.AVERAGE;
    ssm = StringSimMeasure.ISUB;
    primaryStringMatcher = size.equals(SizeCategory.SMALL);
    nss = NeighborSimilarityStrategy.DESCENDANTS;
    directNeighbors = false;
    sType = SelectionType.getSelectionType();
    structuralSelection = size.equals(SizeCategory.HUGE);
    flagSteps = new Vector<Problem>();
    for (Problem f : Problem.values()) flagSteps.add(f);
  }
Beispiel #2
0
 public void openOntologies(URI src, URI tgt) throws OWLOntologyCreationException {
   closeOntologies();
   // Initialize the URIMap and RelationshipMap
   uris = new URIMap();
   rels = new RelationshipMap();
   if (useReasoner) PropertyConfigurator.configure(dir + LOG);
   long time = System.currentTimeMillis() / 1000;
   System.out.println("Loading source ontology");
   source = new Ontology2Match(src);
   time = System.currentTimeMillis() / 1000 - time;
   System.out.println(source.getURI() + " loaded in " + time + " seconds");
   System.out.println("Classes: " + source.classCount());
   System.out.println("Names: " + source.getLexicon().size());
   System.out.println("Individuals: " + source.individualCount());
   System.out.println(
       "Properties: " + (source.dataPropertyCount() + source.objectPropertyCount()));
   time = System.currentTimeMillis() / 1000;
   System.out.println("Loading target ontology");
   target = new Ontology2Match(tgt);
   time = System.currentTimeMillis() / 1000 - time;
   System.out.println(target.getURI() + " loaded in " + time + " seconds");
   System.out.println("Classes: " + target.classCount());
   System.out.println("Names: " + target.getLexicon().size());
   System.out.println("Individuals: " + target.individualCount());
   System.out.println(
       "Properties: " + (target.dataPropertyCount() + target.objectPropertyCount()));
   System.out.println("Direct Relationships: " + rels.relationshipCount());
   time = System.currentTimeMillis() / 1000;
   System.out.println("Running transitive closure on RelationshipMap");
   rels.transitiveClosure();
   time = System.currentTimeMillis() / 1000 - time;
   System.out.println("Transitive closure finished in " + time + " seconds");
   System.out.println("Extended Relationships: " + rels.relationshipCount());
   System.out.println("Disjoints: " + rels.disjointCount());
   // Reset the alignment, mapping, and evaluation
   a = null;
   activeMapping = -1;
   evaluation = null;
   // Refresh the user interface
   if (userInterface != null) userInterface.refresh();
   defaultConfig();
   System.out.println("Finished!");
 }
Beispiel #3
0
 /** @return whether there are classes in both active ontologies */
 public boolean hasClasses() {
   return hasOntologies() && source.classCount() > 0 && target.classCount() > 0;
 }