Examples of TestViewPage


Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

  public Object execute(ExecutionEvent event) throws ExecutionException {
    TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);
    if(!(debugView.getCurrentPage() instanceof TestViewPage)) {
      return Status.CANCEL_STATUS;
    }
    TestViewPage debugPage = (TestViewPage) debugView.getCurrentPage();
   
    TableViewer viewer = debugPage.getViewer();
   
    Shell shell = HandlerUtil.getActiveShell(event);
   
    String evalData = "Test File,Type,TP,FP,FN,Recall,Prec,F-1\n";
   
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

  public Object execute(ExecutionEvent event) throws ExecutionException {
    TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);
    if(!(debugView.getCurrentPage() instanceof TestViewPage)) {
      return Status.CANCEL_STATUS;
    }
    TestViewPage activePage = (TestViewPage) debugView.getCurrentPage();
    IResource resource = activePage.getResource();
    IPath location = resource.getLocation();
    String preFilePath = location.toPortableString();
    File preFile = new File(preFilePath);
    if (preFile.exists() == false || StringUtils.isEmpty(preFilePath)) {
      printErrorDialog("The preprocessing file was not found!");
      return null;
    }
    TypeSystemDescription defaultTypeSystemDescription = null;
    List<String> types = new ArrayList<String>();
    try {
      String tsDesc = RutaProjectUtils.getTypeSystemDescriptorPath(location,
              resource.getProject()).toPortableString();
      defaultTypeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription(
              new XMLInputSource(new File(tsDesc)));
      defaultTypeSystemDescription.resolveImports();
      TypeDescription[] systemTypes = defaultTypeSystemDescription.getTypes();
      Set<String> set = new HashSet<String>();
      for (TypeDescription typeDescription : systemTypes) {
        set.add(typeDescription.getName());
      }
      types.addAll(set);
      Collections.sort(types);
    } catch (InvalidXMLException e) {
      RutaAddonsPlugin.error(e);
    } catch (IOException e) {
      RutaAddonsPlugin.error(e);
    }
    Display display = Display.getDefault();
    Shell shell = new Shell(display, SWT.RESIZE | SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
    shell.setText("Select included types");
    SelectTypesDialog dialog = new SelectTypesDialog(shell, types, activePage.getIncludedTypes());
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    List<String> selectedTypes = dialog.getSelectedTypes();
    activePage.setIncludedTypes(selectedTypes);
    return Status.OK_STATUS;
  }
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

  }

  public void add2Viewer(IPath p) {

    TestViewPage debugPage = (TestViewPage) debugView.getCurrentPage();

    TableViewer viewer = debugPage.getViewer();

    if (viewer.getInput() instanceof ArrayList) {
      ArrayList input = (ArrayList) debugPage.getViewer().getInput();
      input.add(new TestCasData(p));
      viewer.refresh();

      if (input.get(0) != null) {
        TestCasData data = (TestCasData) input.get(0);
        if (data.wasEvaluated()) {
          debugPage.updateSingleTestInformation(data);
        }
      }
    }

  }
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

  public Object execute(ExecutionEvent event) throws ExecutionException {
    TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);
    if(!(debugView.getCurrentPage() instanceof TestViewPage)) {
      return Status.CANCEL_STATUS;
    }
    TestViewPage activePage = (TestViewPage) debugView.getCurrentPage();
    IResource resource = activePage.getResource();
    IPath location = resource.getLocation();
    String preFilePath = location.toPortableString();
    File preFile = new File(preFilePath);
    if (preFile.exists() == false || StringUtils.isEmpty(preFilePath)) {
      printErrorDialog("The preprocessing file was not found!");
      return null;
    }
    TypeSystemDescription defaultTypeSystemDescription = null;
    List<String> types = new ArrayList<String>();
    try {
      String tsDesc = RutaProjectUtils.getTypeSystemDescriptorPath(location, resource.getProject())
              .toPortableString();

      defaultTypeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription(
              new XMLInputSource(new File(tsDesc)));
      defaultTypeSystemDescription.resolveImports();
      TypeDescription[] systemTypes = defaultTypeSystemDescription.getTypes();
      Set<String> set = new HashSet<String>();
      for (TypeDescription typeDescription : systemTypes) {
        set.add(typeDescription.getName());
      }
      types.addAll(set);
      Collections.sort(types);
    } catch (InvalidXMLException e) {
      RutaAddonsPlugin.error(e);
    } catch (IOException e) {
      RutaAddonsPlugin.error(e);
    }

    Display display = Display.getDefault();
    Shell shell = new Shell(display, SWT.RESIZE | SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
    shell.setText("Select excluded types");
    SelectTypesDialog dialog = new SelectTypesDialog(shell, types, activePage.getExcludedTypes());
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    List<String> selectedTypes = dialog.getSelectedTypes();
    activePage.setExcludedTypes(selectedTypes);
    return Status.OK_STATUS;
  }
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

  public Object execute(ExecutionEvent event) throws ExecutionException {
    TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);
    if(!(debugView.getCurrentPage() instanceof TestViewPage)) {
      return Status.CANCEL_STATUS;
    }
    TestViewPage debugPage = (TestViewPage) debugView.getCurrentPage();

    String viewCasName = debugPage.getSelectedViewCasName();
    String scriptName = debugPage.getResource().getLocation().lastSegment();
    RerunHandlerJob job = new RerunHandlerJob(event, scriptName, viewCasName,
            debugPage.getExcludedTypes(), debugPage.getIncludedTypes());

    job.addJobChangeListener(new DebugJobChangeAdapter(debugPage) {
    });

    job.schedule();
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

    @Override
    public IStatus run(IProgressMonitor monitor) {

      // handle GUI
      final TestPageBookView testPageView = (TestPageBookView) HandlerUtil.getActivePart(event);
      final TestViewPage debugPage = (TestViewPage) testPageView.getCurrentPage();
      testPageView.showBusy(true);

      // init variables
      IResource r = debugPage.getResource();
      final IFile fScript = (IFile) r;
      final IProject project = r.getProject();
      final IPath engineDescriptorPath = RutaProjectUtils.getEngineDescriptorPath(r.getLocation(),
              project);
      IPath typeSystemDescriptorPath = RutaProjectUtils.getTypeSystemDescriptorPath(
              fScript.getLocation(), project);

      // show message
      @SuppressWarnings({ "unchecked", "rawtypes" })
      ArrayList<TestCasData> testCasData = (ArrayList) debugPage.getViewer().getInput();
      int numFiles = testCasData.size();
      monitor.beginTask("Running evaluation, please wait", numFiles);

      // switch usage mode: old (only Ruta) vs. new (supports java/uimaFIT AEs)
      IPreferenceStore store = RutaAddonsPlugin.getDefault().getPreferenceStore();
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

  }

  public Object execute(ExecutionEvent event) throws ExecutionException {
    TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);
    TestViewPage activePage = (TestViewPage) debugView.getCurrentPage();
    IResource resource = activePage.getResource();
    IPath location = resource.getLocation();
    String preFilePath = location.toPortableString();
    File preFile = new File(preFilePath);
    if (preFile.exists() == false || StringUtils.isEmpty(preFilePath)) {
      printErrorDialog("The preprocessing file was not found!");
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

  }

  public Object execute(ExecutionEvent event) throws ExecutionException {

    TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);
    TestViewPage debugPage = (TestViewPage) debugView.getCurrentPage();

    String viewCasName = debugPage.getSelectedViewCasName();
    String scriptName = debugPage.getResource().getLocation().lastSegment();
    RerunHandlerJob job = new RerunHandlerJob(event, scriptName, viewCasName);

    job.addJobChangeListener(new DebugJobChangeAdapter(debugPage) {
    });
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

    }

    @Override
    public IStatus run(IProgressMonitor monitor) {
      final TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);
      final TestViewPage debugPage = (TestViewPage) debugView.getCurrentPage();
      debugPage.saveState();
      debugView.showBusy(true);
      IResource r = debugPage.getResource();
      ArrayList<TestCasData> testCasData = (ArrayList) debugPage.getViewer().getInput();
      monitor.beginTask("Running evaluation, please wait", testCasData.size());
      IProject project = r.getProject();
      IPath engineDescriptorPath = RutaProjectUtils.getEngineDescriptorPath(r.getLocation(),
              project);
      try {
        XMLInputSource in = new XMLInputSource(engineDescriptorPath.toPortableString());
        ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
        AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);

        String desc = null;
        desc = engineDescriptorPath.toPortableString();
        XMLInputSource in2 = new XMLInputSource(desc);
        Object descriptor = UIMAFramework.getXMLParser().parse(in2);
        CAS runCas = ae.newCAS();

        for (TestCasData td : testCasData) {
          runCas.reset();
          String elementName = r.getLocation().lastSegment();
          monitor.setTaskName("Evaluating " + td.getPath().lastSegment());
          int lastIndexOf = elementName.lastIndexOf(RutaEngine.SCRIPT_FILE_EXTENSION);
          if (lastIndexOf != -1) {
            elementName = elementName.substring(0, lastIndexOf);
          }

          CAS testCas = getTestCas(descriptor);
          FileInputStream inputStream = null;
          try {
            inputStream = new FileInputStream(new File(td.getPath().toPortableString()));
            XmiCasDeserializer.deserialize(inputStream, testCas, true);
          } finally {
            if (inputStream != null) {
              inputStream.close();
            }
          }

          for (Iterator<CAS> iterator = testCas.getViewIterator(); iterator.hasNext();) {
            CAS each = iterator.next();
            String viewName = each.getViewName();
            try {
              CAS view = runCas.getView(viewName);
              view.setDocumentText(each.getDocumentText());

            } catch (Exception e) {
              RutaAddonsPlugin.error(e);
            }
          }

          testCas = testCas.getView(viewCasName);
          runCas = runCas.getView(viewCasName);

          IPreferenceStore store = RutaAddonsPlugin.getDefault().getPreferenceStore();
          String factoryName = store.getString(TestingPreferenceConstants.EVALUATOR_FACTORY);
          ICasEvaluator evaluator = RutaAddonsPlugin.getCasEvaluatorFactoryById(factoryName)
                  .createEvaluator();

          ae.process(runCas);
          CAS resultCas = evaluator.evaluate(testCas, runCas, debugPage.getExcludedTypes());

          IPath path2Test = td.getPath().removeLastSegments(1);

          IPath estimatedTestPath = project.getFullPath().append(
                  RutaProjectUtils.getDefaultTestLocation());
          IPath path2recource = r.getFullPath();
          IPath projectRelativePath2Script = path2recource.removeFirstSegments(2);
          IPath estimatedTestFolderPath = estimatedTestPath.append(projectRelativePath2Script
                  .removeFileExtension());

          IPath path2Result = path2Test.append(TestCasData.RESULT_FOLDER);
          IPath path2ResultFile = path2Result.append(td.getPath().removeFileExtension()
                  .lastSegment()
                  + ".result.xmi");

          if (!path2Test.toOSString().contains(estimatedTestFolderPath.toOSString())) {
            path2Result = project.getLocation()
                    .append(RutaProjectUtils.getDefaultTestLocation())
                    .append(RutaProjectUtils.getDefaultTempTestLocation());
            path2ResultFile = path2Result.append(td.getPath().removeFileExtension().lastSegment()
                    + ".result.xmi");
          }

          File resultFile = new File(path2ResultFile.toPortableString());
          writeXmi(resultCas, resultFile);

          td.setResultPath(path2ResultFile);

          // calculateEvaluatData(td, resultCas);

          EvalDataProcessor.calculateEvaluatData(td, resultCas);

          debugView.getDefaultPage().getControl().getDisplay().asyncExec(new Runnable() {
            public void run() {
              debugPage.getViewer().refresh();
            }
          });
          monitor.worked(1);
          r.getProject().getFolder(path2Result)
                  .refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
View Full Code Here

Examples of org.apache.uima.ruta.testing.ui.views.TestViewPage

  }

  public void add2Viewer(IPath p) {

    TestViewPage debugPage = (TestViewPage) debugView.getCurrentPage();

    TableViewer viewer = debugPage.getViewer();

    if (viewer.getInput() instanceof ArrayList) {
      ArrayList input = (ArrayList) debugPage.getViewer().getInput();
      input.add(new TestCasData(p));
      viewer.refresh();

      if (input.get(0) != null) {
        TestCasData data = (TestCasData) input.get(0);
        if (data.wasEvaluated()) {
          debugPage.updateSingleTestInformation(data);
        }
      }
    }

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.