Package org.apache.uima.internal.util

Examples of org.apache.uima.internal.util.Timer


    addRecentDescFile(descriptorFile);
    setWaitCursor();
    if (descriptorFile.exists() && descriptorFile.isFile()) {
      this.annotOpenDir = descriptorFile.getParentFile();
    }
    Timer time = new Timer();
    time.start();
    boolean success = false;
    try {
      success = setupAE(descriptorFile);
    } catch (Exception e) {
      handleException(e);
    } catch (NoClassDefFoundError e) {
      // We don't want to catch all errors, but some are ok.
      handleException(e);
    }
    time.stop();
    if (!success) {
      setStatusbarMessage("Failed to load AE specifier: " + descriptorFile.getName());
      this.reRunMenu.setText("Run AE");
      setAEStatusMessage();
      resetCursor();
      return;
    }
    if (this.ae != null) {
      this.aeDescriptorFile = descriptorFile;
      String annotName = this.ae.getAnalysisEngineMetaData().getName();
      this.reRunMenu.setText("Run " + annotName);
      this.reRunMenu.setEnabled(true);
      this.runOnCasMenuItem.setText("Run " + annotName + " on CAS");
      setAEStatusMessage();
      setStatusbarMessage("Done loading AE " + annotName + " in " + time.getTimeSpan() + ".");
    }
    // Check for CAS multiplier
    // TODO: properly handle CAS multiplication
    if (this.ae != null) {
      if (this.ae.getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()) {
View Full Code Here


  }

  public void loadXmiFile(File xmiCasFile) {
    try {
      setXcasFileOpenDir(xmiCasFile.getParentFile());
      Timer time = new Timer();
      time.start();
      SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
      XmiCasDeserializer xmiCasDeserializer = new XmiCasDeserializer(getCas().getTypeSystem());
      getCas().reset();
      parser.parse(xmiCasFile, xmiCasDeserializer.getXmiCasHandler(getCas(), true));
      time.stop();
      handleSofas();

      setTitle("XMI CAS");
      updateIndexTree(true);
      setRunOnCasEnabled();
      setEnableCasFileReadingAndWriting();
      setStatusbarMessage("Done loading XMI CAS file in " + time.getTimeSpan() + ".");
    } catch (Exception e) {
      e.printStackTrace();
      handleException(e);
    }
  }
View Full Code Here

    init();
  }

  public void runAE(boolean doCasReset) {
    setStatusbarMessage("Running Annotator.");
    Timer timer = new Timer();
    timer.start();
    if (this.ae == null) {
      JOptionPane.showMessageDialog(this, "No AE loaded.", "Error", JOptionPane.ERROR_MESSAGE);
      return;
    }
    internalRunAE(doCasReset);
    timer.stop();
    setStatusbarMessage("Done running AE " + this.ae.getAnalysisEngineMetaData().getName() + " in "
        + timer.getTimeSpan() + ".");
    updateIndexTree(true);
    this.allAnnotationViewerItem.setEnabled(false);
    this.isDirty = false;
    this.runOnCasMenuItem.setEnabled(true);
  }
View Full Code Here

  public void loadAEDescriptor(File descriptorFile) {
    setWaitCursor();
    if (descriptorFile.exists() && descriptorFile.isFile()) {
      this.annotOpenDir = descriptorFile.getParentFile();
    }
    Timer time = new Timer();
    time.start();
    boolean success = false;
    try {
      success = setupAE(descriptorFile);
    } catch (Exception e) {
      handleException(e);
    } catch (NoClassDefFoundError e) {
      // We don't want to catch all errors, but some are ok.
      handleException(e);
    }
    time.stop();
    addRecentDescFile(descriptorFile);
    if (!success) {
      setStatusbarMessage("Failed to load AE specifier: " + descriptorFile.getName());
      this.reRunMenu.setText("Run AE");
      setAEStatusMessage();
      resetCursor();
      return;
    }
    if (this.ae != null) {
      this.aeDescriptorFile = descriptorFile;
      String annotName = this.ae.getAnalysisEngineMetaData().getName();
      this.reRunMenu.setText("Run " + annotName);
      this.reRunMenu.setEnabled(true);
      this.runOnCasMenuItem.setText("Run " + annotName + " on CAS");
      setAEStatusMessage();
      setStatusbarMessage("Done loading AE " + annotName + " in " + time.getTimeSpan() + ".");
    }
    // Check for CAS multiplier
    // TODO: properly handle CAS multiplication
    if (this.ae != null) {
      if (this.ae.getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()) {
View Full Code Here

  public void loadAEDescriptor(File descriptorFile) {
    setWaitCursor();
    if (descriptorFile.exists() && descriptorFile.isFile()) {
      this.annotOpenDir = descriptorFile.getParentFile();
    }
    Timer time = new Timer();
    time.start();
    boolean success = false;
    try {
      success = setupAE(descriptorFile);
    } catch (Exception e) {
      handleException(e);
    } catch (NoClassDefFoundError e) {
      // We don't want to catch all errors, but some are ok.
      handleException(e);
    }
    time.stop();
    addRecentDescFile(descriptorFile);
    if (!success) {
      setStatusbarMessage("Failed to load AE specifier: " + descriptorFile.getName());
      this.reRunMenu.setText("Run AE");
      setAEStatusMessage();
      resetCursor();
      return;
    }
    if (this.ae != null) {
      String annotName = this.ae.getAnalysisEngineMetaData().getName();
      this.reRunMenu.setText("Run " + annotName);
      this.reRunMenu.setEnabled(true);
      this.runOnCasMenuItem.setText("Run " + annotName + " on CAS");
      setAEStatusMessage();
      setStatusbarMessage("Done loading AE " + annotName + " in " + time.getTimeSpan() + ".");
    }
    // Check for CAS multiplier
    // TODO: properly handle CAS multiplication
    if (this.ae != null) {
      if (this.ae.getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()) {
View Full Code Here

    }
  }

  public void runAE(boolean doCasReset) {
    setStatusbarMessage("Running Annotator.");
    Timer timer = new Timer();
    timer.start();
    if (this.ae == null) {
      JOptionPane.showMessageDialog(this, "No AE loaded.", "Error", JOptionPane.ERROR_MESSAGE);
      return;
    }
    internalRunAE(doCasReset);
    timer.stop();
    setStatusbarMessage("Done running AE " + this.ae.getAnalysisEngineMetaData().getName() + " in "
        + timer.getTimeSpan() + ".");
    updateIndexTree(true);
    this.allAnnotViewerItem.setEnabled(false);
    this.isDirty = false;
    this.runOnCasMenuItem.setEnabled(true);
  }
View Full Code Here

      if (rc == JFileChooser.APPROVE_OPTION) {
        MainFrame.this.textFile = fileChooser.getSelectedFile();
        if (MainFrame.this.textFile.exists() && MainFrame.this.textFile.isFile()) {
          MainFrame.this.fileOpenDir = MainFrame.this.textFile.getParentFile();
        }
        Timer time = new Timer();
        time.start();
        loadFile();
        time.stop();
        resetTrees();
        MainFrame.this.fileSaveItem.setEnabled(true);
        MainFrame.this.undoMgr.discardAllEdits();
        setFileStatusMessage();
        setStatusbarMessage("Done loading text file " + MainFrame.this.textFile.getName() + " in "
            + time.getTimeSpan() + ".");
      }
    }
View Full Code Here

      if (rc == JFileChooser.APPROVE_OPTION) {
        File xcasFile = fileChooser.getSelectedFile();
        if (xcasFile.exists() && xcasFile.isFile()) {
          try {
            MainFrame.this.xcasFileOpenDir = xcasFile.getParentFile();
            Timer time = new Timer();
            time.start();
            SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
            XCASDeserializer xcasDeserializer = new XCASDeserializer(MainFrame.this.cas
                .getTypeSystem());
            MainFrame.this.cas.reset();
            parser.parse(xcasFile, xcasDeserializer.getXCASHandler(MainFrame.this.cas));
            time.stop();
            // Populate sofa combo box with the names of all text
            // Sofas in the CAS
            MainFrame.this.disableSofaListener = true;
            String currentView = (String) MainFrame.this.sofaSelectionComboBox.getSelectedItem();
            MainFrame.this.sofaSelectionComboBox.removeAllItems();
            MainFrame.this.sofaSelectionComboBox.addItem(CAS.NAME_DEFAULT_SOFA);
            Iterator sofas = ((CASImpl) MainFrame.this.cas).getBaseCAS().getSofaIterator();
            Feature sofaIdFeat = MainFrame.this.cas.getTypeSystem().getFeatureByFullName(
                CAS.FEATURE_FULL_NAME_SOFAID);
            boolean nonDefaultSofaFound = false;
            while (sofas.hasNext()) {
              SofaFS sofa = (SofaFS) sofas.next();
              String sofaId = sofa.getStringValue(sofaIdFeat);
              if (!CAS.NAME_DEFAULT_SOFA.equals(sofaId)) {
                MainFrame.this.sofaSelectionComboBox.addItem(sofaId);
                nonDefaultSofaFound = true;
              }
            }
            // reuse last selected view if found in new CAS
            int newIndex = 0;
            String newView = CAS.NAME_DEFAULT_SOFA;
            for (int i = 0; i < MainFrame.this.sofaSelectionComboBox.getItemCount(); i++) {
              if (currentView.equals(MainFrame.this.sofaSelectionComboBox.getItemAt(i))) {
                newIndex = i;
                newView = currentView;
                break;
              }
            }
            // make sofa selector visible if any text sofa other
            // than the default was found
            MainFrame.this.sofaSelectionPanel.setVisible(nonDefaultSofaFound);
            MainFrame.this.cas = MainFrame.this.cas.getView(newView);
            MainFrame.this.disableSofaListener = false;

            MainFrame.this.sofaSelectionComboBox.setSelectedIndex(newIndex);
            String text = MainFrame.this.cas.getDocumentText();
            if (text == null) {
              text = MainFrame.this.cas.getSofaDataURI();
              if (text != null) {
                text = "SofaURI = " + text;
              } else {
                if (null != MainFrame.this.cas.getSofaDataArray()) {
                  text = "Sofa array with mime type = "
                      + MainFrame.this.cas.getSofa().getSofaMime();
                }
              }
            }
            MainFrame.this.textArea.setText(text);
            if (text == null) {
              MainFrame.this.textArea.repaint();
            }

            MainFrame.this.setTitle("XCAS");
            MainFrame.this.updateIndexTree(true);
            MainFrame.this.runOnCasMenuItem.setEnabled(true);
            setStatusbarMessage("Done loading XCAS file in " + time.getTimeSpan() + ".");
          } catch (Exception e) {
            e.printStackTrace();
            handleException(e);
          }
        }
View Full Code Here

      if (rc == JFileChooser.APPROVE_OPTION) {
        File tsFile = fileChooser.getSelectedFile();
        if (tsFile.exists() && tsFile.isFile()) {
          try {
            MainFrame.this.xcasFileOpenDir = tsFile.getParentFile();
            Timer time = new Timer();
            time.start();
            Object descriptor = UIMAFramework.getXMLParser().parse(new XMLInputSource(tsFile));
            // instantiate CAS to get type system. Also build style
            // map file if there is none.
            TypeSystemDescription tsDesc = (TypeSystemDescription) descriptor;
            tsDesc.resolveImports();
            if (MainFrame.this.ae != null) {
              MainFrame.this.ae.destroy();
              MainFrame.this.ae = null;
            }
            MainFrame.this.cas = CasCreationUtils
                .createCas(tsDesc, null, new FsIndexDescription[0]);
            MainFrame.this.runOnCasMenuItem.setEnabled(false);
            MainFrame.this.reRunMenu.setEnabled(false);
            MainFrame.this.textArea.setText("");
            MainFrame.this.resetTrees();
            MainFrame.this.tsViewerItem.setEnabled(true);
            MainFrame.this.xcasReadItem.setEnabled(true);
            time.stop();
            setStatusbarMessage("Done loading type system file in " + time.getTimeSpan() + ".");
          } catch (Exception e) {
            e.printStackTrace();
            handleException(e);
          }
        }
View Full Code Here

    if (rc == JFileChooser.APPROVE_OPTION) {
      File xmiCasFile = fileChooser.getSelectedFile();
      if (xmiCasFile.exists() && xmiCasFile.isFile()) {
        try {
          this.main.setXcasFileOpenDir(xmiCasFile.getParentFile());
          Timer time = new Timer();
          time.start();
          SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
          XmiCasDeserializer xmiCasDeserializer = new XmiCasDeserializer(this.main.getCas()
              .getTypeSystem());
          this.main.getCas().reset();
          parser.parse(xmiCasFile, xmiCasDeserializer.getXmiCasHandler(this.main.getCas()));
          time.stop();
          this.main.handleSofas();

          this.main.setTitle("XMI CAS");
          this.main.updateIndexTree(true);
          this.main.setRunOnCasEnabled();
          this.main.setEnableCasFileReadingAndWriting();
          this.main.setStatusbarMessage("Done loading XMI CAS file in " + time.getTimeSpan() + ".");
        } catch (Exception e) {
          e.printStackTrace();
          this.main.handleException(e);
        }
      }
View Full Code Here

TOP

Related Classes of org.apache.uima.internal.util.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.