コード例 #1
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
  /** Evaluates the current alignment using the reference alignment */
  public void evaluate() {
    boolean gui = userInterface != null;
    int[] eval = a.evaluate(ref);
    int found = a.size() - eval[1];
    int correct = eval[0];
    int total = ref.size() - ref.countConflicts();

    precision = 1.0 * correct / found;
    String prc = Math.round(precision * 1000) / 10.0 + "%";
    recall = 1.0 * correct / total;
    String rec = Math.round(recall * 1000) / 10.0 + "%";
    fMeasure = 2 * precision * recall / (precision + recall);
    String fms = Math.round(fMeasure * 1000) / 10.0 + "%";

    if (gui) {
      evaluation = "Precision: " + prc + "; Recall: " + rec + "; F-measure: " + fms;
      userInterface.refresh();
    } else
      evaluation =
          "Precision\tRecall\tF-measure\tFound\tCorrect\tReference\n"
              + prc
              + "\t"
              + rec
              + "\t"
              + fms
              + "\t"
              + found
              + "\t"
              + correct
              + "\t"
              + total;
  }
コード例 #2
0
  public SearchAlignment() {
    super();

    this.setTitle("Search Alignment");
    this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    this.setPreferredSize(new Dimension(700, 140));

    AML aml = AML.getInstance();

    // The containing panel
    dialogPanel = new JPanel();
    cl = new CardLayout();
    dialogPanel.setLayout(cl);

    // The search panel
    JLabel desc = new JLabel("Enter Search Term: (min 3 characters)");
    Font font = desc.getFont();
    boldFont = new Font(font.getFontName(), Font.BOLD, font.getSize());
    desc.setFont(boldFont);
    JPanel labelPanel = new JPanel();
    labelPanel.add(desc);
    Alignment a = AML.getInstance().getAlignment();
    int total = a.size();
    mappings = new ArrayList<String>(total);
    for (int i = 0; i < total; i++) {
      Mapping m = a.get(i);
      String map = aml.getSource().getName(m.getSourceId());
      map += " = ";
      map += aml.getTarget().getName(m.getTargetId());
      mappings.add(map);
    }
    searchField = new JTextArea(1, 60);
    searchField.setEditable(true);
    AutoCompleteDecorator.decorate(searchField, mappings, false);
    JPanel selectionPanel = new JPanel();
    selectionPanel.add(searchField);
    cancel = new JButton("Cancel");
    cancel.setPreferredSize(new Dimension(70, 28));
    cancel.addActionListener(this);
    find = new JButton("Find");
    find.setPreferredSize(new Dimension(70, 28));
    find.addActionListener(this);
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(cancel);
    buttonPanel.add(find);

    searchPanel = new JPanel();
    searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.PAGE_AXIS));
    searchPanel.add(labelPanel);
    searchPanel.add(selectionPanel);
    searchPanel.add(buttonPanel);

    dialogPanel.add(searchPanel, "Search");
    cl.show(dialogPanel, "Search");

    this.add(dialogPanel);
    this.pack();
    this.setVisible(true);
  }
コード例 #3
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
 public void removeIncorrect() {
   Alignment reviewed = new Alignment();
   for (Mapping m : a) if (!m.getStatus().equals(MappingStatus.INCORRECT)) reviewed.add(m);
   if (a.size() > reviewed.size()) {
     aml.setAlignment(reviewed);
     if (a.size() > 0) activeMapping = 0;
     if (userInterface != null) userInterface.refresh();
     needSave = true;
   }
 }
コード例 #4
0
  public static Alignment tfIdfMainParse(String sourcePath, String targetPath)
      throws OWLOntologyCreationException {
    double sim = 0.0d;
    csMaps = new Alignment();
    source = new Ontology2Match(sourcePath);
    target = new Ontology2Match(targetPath);

    String sName, tName;
    List<double[]> docsrcVector, doctgtVector = new ArrayList<double[]>();

    // Get class Names of the source and target
    Set<Integer> sourceKeys = source.getClasses();
    Set<Integer> targetKeys = target.getClasses();

    // Parse Class Names of Source and Target
    for (Integer i : sourceKeys) {
      for (Integer j : targetKeys) {
        sName = source.getName(i);
        tName = target.getName(j);
        sim = calcCosSim(sName, tName);
        csMaps.add(new Mapping(i, j, sim));
      }
    }

    // Get Data Properties of the source and target
    Set<Integer> sDProp = source.getDataProperties();
    Set<Integer> tDProp = target.getDataProperties();

    // Parse Data Properties of Source and Target
    for (Integer i : sDProp) {
      for (Integer j : tDProp) {
        sName = source.getName(i);
        tName = target.getName(j);
        sim = calcCosSim(sName, tName);
        csMaps.add(new Mapping(i, j, sim));
      }
    }

    // Get Object Properties of the source and target
    Set<Integer> sOProp = source.getObjectProperties();
    Set<Integer> tOProp = target.getObjectProperties();

    // Parse Object Properties of Source and Target
    for (Integer i : sOProp) {
      for (Integer j : tOProp) {
        sName = source.getName(i);
        tName = target.getName(j);
        sim = calcCosSim(sName, tName);
        csMaps.add(new Mapping(i, j, sim));
      }
    }
    return csMaps;
  }
コード例 #5
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
 /**
  * Opens an alignment from a file as the active alignment
  *
  * @param path: the path to the alignment file
  * @throws Exception if the alignment file can't be read or interpreted
  */
 public void openAlignment(String path) throws Exception {
   a = new Alignment(path);
   evaluation = null;
   if (a.size() > 0) activeMapping = 0;
   if (userInterface != null) userInterface.refresh();
   needSave = false;
 }
コード例 #6
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
 public void setAlignment(Alignment maps) {
   a = maps;
   if (a.size() > 0) activeMapping = 0;
   qf = null;
   evaluation = null;
   rep = null;
   needSave = false;
 }
コード例 #7
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
 /** Matches the active ontologies using manual configurations */
 public void matchManual() {
   im = new InteractionManager();
   ManualMatcher.match();
   evaluation = null;
   rep = null;
   if (a.size() > 0) activeMapping = 0;
   if (userInterface != null) userInterface.refresh();
   needSave = true;
 }
コード例 #8
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
 /** Matches the active ontologies using the default configuration */
 public void matchAuto() {
   defaultConfig();
   im = new InteractionManager();
   AutomaticMatcher.match();
   evaluation = null;
   rep = null;
   if (a.size() > 0) activeMapping = 0;
   if (userInterface != null) userInterface.refresh();
   needSave = true;
 }
コード例 #9
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
 public void sortDescending() {
   a.sortDescending();
   if (a.size() > 0) activeMapping = 0;
   if (userInterface != null) userInterface.refresh();
 }
コード例 #10
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
 public void saveAlignmentTSV(String file) throws Exception {
   a.saveTSV(file);
   needSave = false;
 }
コード例 #11
0
ファイル: AML.java プロジェクト: tetherless-world/linkipedia
 /** @return whether there is a non-empty active alignment */
 public boolean hasAlignment() {
   return a != null && a.size() > 0;
 }