public FlagOptions() {
    // Initialize
    super();
    this.setMinimumSize(new Dimension(200, 100));
    // Get the AML instance
    aml = AML.getInstance();
    // And the lists of match steps & match configurations
    selectedSteps = aml.getFlagSteps();
    flaggers = new Vector<JCheckBox>();
    for (Problem m : Problem.values()) {
      JCheckBox cb = new JCheckBox(m.toString());
      cb.setSelected(selectedSteps.contains(m));
      flaggers.add(cb);
    }

    // Set the title and modality
    this.setTitle("Flagging Options");
    this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    // Match Steps
    JPanel subPanel = new JPanel();
    JPanel flaggerPanel = new JPanel();
    flaggerPanel.setLayout(new BoxLayout(flaggerPanel, BoxLayout.Y_AXIS));
    for (JCheckBox cb : flaggers) flaggerPanel.add(cb);
    subPanel.add(flaggerPanel);
    panel.add(subPanel);

    // Button Panel
    cancel = new JButton("Cancel");
    cancel.setPreferredSize(new Dimension(80, 28));
    cancel.addActionListener(this);
    flag = new JButton("Flag");
    flag.setPreferredSize(new Dimension(80, 28));
    flag.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    buttonPanel.add(cancel);
    buttonPanel.add(flag);
    panel.add(buttonPanel);

    add(panel);

    this.pack();
    GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
    int left = g.getCenterPoint().x - (int) (this.getPreferredSize().width / 2);
    this.setLocation(left, 0);
    this.setVisible(true);
  }
Beispiel #2
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);
  }
 @Override
 public void actionPerformed(ActionEvent e) {
   Object o = e.getSource();
   if (o == cancel) this.dispose();
   else if (o == flag) {
     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     Vector<Problem> selection = new Vector<Problem>();
     for (int i = 0; i < flaggers.size(); i++)
       if (flaggers.get(i).isSelected()) selection.add(Problem.values()[i]);
     aml.setFlagSteps(selection);
     c = new Console();
     c.addWindowListener(this);
     console = new Thread(c);
     console.start();
     action = new Thread(this);
     action.start();
   }
 }