You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2007/01/22 20:53:02 UTC
svn commit: r498763 - in
/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools:
docanalyzer/DocumentAnalyzer.java viewer/CasAnnotationViewer.java
Author: alally
Date: Mon Jan 22 11:53:00 2007
New Revision: 498763
URL: http://svn.apache.org/viewvc?view=rev&rev=498763
Log:
Fixed DocumentAnalyzer so it doesn't have to re-contact remote
services after processing completes in order to get their metadata.
Also fixed some problems with style maps not working properly.
UIMA-214: http://issues.apache.org/jira/browse/UIMA-214
Modified:
incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/docanalyzer/DocumentAnalyzer.java
incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/viewer/CasAnnotationViewer.java
Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/docanalyzer/DocumentAnalyzer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/docanalyzer/DocumentAnalyzer.java?view=diff&rev=498763&r1=498762&r2=498763
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/docanalyzer/DocumentAnalyzer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/docanalyzer/DocumentAnalyzer.java Mon Jan 22 11:53:00 2007
@@ -94,7 +94,6 @@
import org.apache.uima.tools.util.gui.Caption;
import org.apache.uima.tools.util.gui.SplashScreenDialog;
import org.apache.uima.tools.util.gui.SpringUtilities;
-import org.apache.uima.tools.util.htmlview.AnnotationViewGenerator;
import org.apache.uima.util.AnalysisEnginePerformanceReports;
import org.apache.uima.util.CasCreationUtils;
import org.apache.uima.util.InvalidXMLException;
@@ -162,8 +161,6 @@
protected String interactiveTempFN = "__DAtemp__.txt"; // JMP
- private AnnotationViewGenerator annotationViewGenerator;
-
private JDialog aboutDialog;
private int numDocs;
@@ -172,8 +169,6 @@
private AnalysisEngine ae;
- private File tempDir = new File(System.getProperty("java.io.tmpdir"));
-
/** Directory in which this program will write its output files. */
private File outputDirectory;
@@ -467,7 +462,6 @@
// load user preferences
restorePreferences();
- annotationViewGenerator = new AnnotationViewGenerator(tempDir);
progressTimer = new Timer(100, new ActionListener() {
public void actionPerformed(ActionEvent ee) {
checkProgressMonitor();
@@ -496,30 +490,17 @@
}
- // moves this one to top
+ // View button clicked
public void actionPerformed(ActionEvent e) {
savePreferences();
try {
aeSpecifierFile = new File(xmlFileSelector.getSelected());
- XMLInputSource in = new XMLInputSource(aeSpecifierFile);
- // ResourceSpecifier aeSpecifier = UIMAFramework.getXMLParser()
- // .parseResourceSpecifier(in);
- AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
- in);
-
- // this generates style map file if one does not currently exist
- if (!prefsMed.getStylemapFile().exists()) {
- annotationViewGenerator.autoGenerateStyleMapFile(aed.getAnalysisEngineMetaData(), prefsMed
- .getStylemapFile());
- }
- } catch (InvalidXMLException e1) {
- e1.printStackTrace();
- } catch (IOException e1) {
- e1.printStackTrace();
+ interactive = false; // prevent re-viewing temp file
+ showAnalysisResults(outputDirectory);
+ }
+ catch (Exception ex) {
+ displayError(ex);
}
- interactive = false; // prevent re-viewing temp file
- showAnalysisResults(outputDirectory);
-
}
/**
@@ -753,12 +734,6 @@
*/
public void showAnalysisResults(AnalysisEnginePerformanceReports aReports, File aOutputDir) {
statsString = ("PERFORMANCE STATS\n-------------\n\n" + aReports);
- try {
- cas = createCasFromDescriptor(prefsMed.getTAEfile());
- } catch (Exception e) {
- displayError(e);
- }
- currentTypeSystem = cas.getTypeSystem();
show_analysis(aOutputDir);
}
@@ -773,14 +748,21 @@
}
statsString = null;
- // what is this code doing??? - APL
- StyleMapEditor sedit = new StyleMapEditor(this, cas);
- String sXml = readStylemapFile(prefsMed.getStylemapFile());
- ArrayList sme = sedit.parseStyleList(sXml);
- currentTaeOutputTypes = new String[sme.size()];
- for (int i = 0; i < sme.size(); i++) {
- StyleMapEntry e = (StyleMapEntry) sme.get(i);
- currentTaeOutputTypes[i] = e.getAnnotationTypeName();
+
+ // Not sure if the following code makes sense... If a style map file exists,
+ // this restricts the set of types displayed by the viewer to only the types
+ // in that file. But why is this only done in "View" mode? It seems like this
+ // belongs in XCasAnnotationViewerDialog with the other code that sets up the
+ // viewer (e.g., the colors) from the style map file.
+ if (prefsMed.getStylemapFile().exists()) {
+ StyleMapEditor sedit = new StyleMapEditor(this, cas);
+ String sXml = readStylemapFile(prefsMed.getStylemapFile());
+ ArrayList sme = sedit.parseStyleList(sXml);
+ currentTaeOutputTypes = new String[sme.size()];
+ for (int i = 0; i < sme.size(); i++) {
+ StyleMapEntry e = (StyleMapEntry) sme.get(i);
+ currentTaeOutputTypes[i] = e.getAnnotationTypeName();
+ }
}
show_analysis(aOutputDir);
}
@@ -800,8 +782,8 @@
if (spec instanceof AnalysisEngineDescription) {
return CasCreationUtils.createCas((AnalysisEngineDescription) spec);
} else {
- AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(spec);
- return CasCreationUtils.createCas(ae.getAnalysisEngineMetaData());
+ AnalysisEngine currentAe = UIMAFramework.produceAnalysisEngine(spec);
+ return CasCreationUtils.createCas(currentAe.getAnalysisEngineMetaData());
}
}
@@ -1178,10 +1160,7 @@
aggDesc.getAnalysisEngineMetaData().setName("DocumentAnalyzerAE");
aggDesc.getAnalysisEngineMetaData().setFlowConstraints(flow);
aggDesc.getAnalysisEngineMetaData().getOperationalProperties().setMultipleDeploymentAllowed(
- false);
-
-
-
+ false);
progressMonitor.setProgress(1);
// instantiate AE
@@ -1190,20 +1169,17 @@
progressMonitor.setProgress(2);
- // this generates style map file if one does not currently exist
- if (!prefsMed.getStylemapFile().exists()) {
- annotationViewGenerator.autoGenerateStyleMapFile(ae, prefsMed.getStylemapFile());
- }
-
// register callback listener
mCPM.addStatusCallbackListener(DocumentAnalyzer.this);
- // save type system for later use in deserializing XCASes
+ // create a CAS, including all types from all components, that
+ // we'll later use for deserializing XCASes
List descriptorList = new ArrayList();
descriptorList.add(collectionReaderDesc);
descriptorList.add(ae.getMetaData());
descriptorList.add(casConsumerDesc);
- currentTypeSystem = CasCreationUtils.createCas(descriptorList).getTypeSystem();
+ cas = CasCreationUtils.createCas(descriptorList);
+ currentTypeSystem = cas.getTypeSystem();
// save AE output types for later use in configuring viewer
if (aeSpecifier instanceof AnalysisEngineDescription) {
Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/viewer/CasAnnotationViewer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/viewer/CasAnnotationViewer.java?view=diff&rev=498763&r1=498762&r2=498763
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/viewer/CasAnnotationViewer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/viewer/CasAnnotationViewer.java Mon Jan 22 11:53:00 2007
@@ -136,12 +136,12 @@
private static final short MODE_ENTITIES = 1;
- private static ArrayList userTypes = null;
+ private ArrayList userTypes = null;
/**
* @return Returns the userTypes.
*/
- public static ArrayList getUserTypes() {
+ public ArrayList getUserTypes() {
return userTypes;
}
@@ -149,8 +149,8 @@
* @param userTypes
* The userTypes to set.
*/
- public static void setUserTypes(ArrayList userTypes) {
- CasAnnotationViewer.userTypes = userTypes;
+ public void setUserTypes(ArrayList userTypes) {
+ this.userTypes = userTypes;
}
// colors to use for highlighting annotations