Author: pkluegl
Date: Thu Nov 7 08:27:02 2019
New Revision: 1869491
URL: http://svn.apache.org/viewvc?rev=1869491&view=rev
Log:
UIMA-5934: syso cleanup
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/EditDistanceCostMap.java
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaAutoEditStrategy.java
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/wizards/RutaProjectCreationWizard.java
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPLearner.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPatternSegment.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/trabal/TrabalLearner.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/wien/Wien.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/TextRulerView.java
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
(original)
+++
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
Thu Nov 7 08:27:02 2019
@@ -366,9 +366,6 @@ public class RutaStream extends FSIterat
private boolean indexType(Type type) {
if (typeUsage != null) {
boolean contains =
typeUsage.getUsedTypesWithSubTypes().contains(type.getName());
- // if(!contains) {
- // System.out.println(type.getShortName());
- // }
return contains;
}
return true;
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
(original)
+++
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
Thu Nov 7 08:27:02 2019
@@ -20,6 +20,8 @@
package org.apache.uima.ruta.action;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.Feature;
@@ -73,9 +75,10 @@ public class GetFeatureAction extends Ab
List<AnnotationFS> matchedAnnotations =
match.getMatchedAnnotationsOfElement(element);
for (AnnotationFS annotationFS : matchedAnnotations) {
if (annotationFS.getType().getFeatureByBaseName(stringValue) == null) {
- // TODO replace syso by logger
- System.out.println("Can't access feature " + stringValue
- + ", because it's not defined in the matched type: " +
annotationFS.getType());
+ Logger.getLogger(this.getClass().getName()).log(Level.INFO,
+ "Can't access feature " + stringValue
+ + ", because it's not defined in the matched type: "
+ + annotationFS.getType().getName());
return;
}
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java
(original)
+++
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java
Thu Nov 7 08:27:02 2019
@@ -50,6 +50,7 @@ import org.apache.uima.ruta.extensions.R
import org.apache.uima.ruta.parser.RutaLexer;
import org.apache.uima.ruta.parser.RutaParser;
import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.Level;
public class RutaDescriptorFactory {
@@ -229,7 +230,8 @@ public class RutaDescriptorFactory {
}
}
} catch (Exception e) {
- // System.out.println("EXTENSION ERROR: " + each);
+ UIMAFramework.getLogger(getClass()).log(Level.WARNING,
+ "Error loading external extension " + each, e);
}
}
return factory;
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/EditDistanceCostMap.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/EditDistanceCostMap.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/EditDistanceCostMap.java
(original)
+++
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/EditDistanceCostMap.java
Thu Nov 7 08:27:02 2019
@@ -29,6 +29,9 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.util.Level;
+
/**
* Class EditDistanceMap.
*
@@ -155,7 +158,7 @@ public class EditDistanceCostMap {
try {
br = new BufferedReader(new FileReader(new File(file)));
} catch (FileNotFoundException e) {
- System.err.println("File not found.");
+ UIMAFramework.getLogger(getClass()).log(Level.WARNING, "File not found:
" + file, e);
return false;
}
@@ -188,7 +191,6 @@ public class EditDistanceCostMap {
// The "strings" should have just one character.
if (cArray.length != 1) {
- System.err.println("Invalid format.");
retValue = false;
continue;
}
@@ -207,7 +209,6 @@ public class EditDistanceCostMap {
char[] dArray = line[2].toCharArray();
if (cArray.length != 1 || dArray.length != 1) {
- System.err.println("Invalid format.");
retValue = false;
continue;
}
@@ -221,18 +222,14 @@ public class EditDistanceCostMap {
defaultCosts = value;
} else {
- System.err.println("Invalid EditDistance" + "CostMap-Operation.");
retValue = false;
}
} catch (StringIndexOutOfBoundsException e) {
- System.err.println("String Index out of bounds.");
retValue = false;
} catch (IndexOutOfBoundsException e) {
- System.err.println("Index out of bounds.");
retValue = false;
} catch (NumberFormatException e) {
- System.err.println("Number Format Error.");
retValue = false;
}
}
@@ -240,7 +237,6 @@ public class EditDistanceCostMap {
br.close();
} catch (IOException e) {
- System.err.println("IO-Error.");
return false;
}
Modified:
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java
(original)
+++
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java
Thu Nov 7 08:27:02 2019
@@ -113,6 +113,7 @@ public class RutaGEConstraint implements
ae.reconfigure();
}
+ @Override
public Double processConstraint(CAS cas) throws Exception {
if (!initalized) {
initialize();
@@ -120,8 +121,8 @@ public class RutaGEConstraint implements
int runCount = 0;
int printCount = 0;
ArrayList<Double[]> results = new ArrayList<Double[]>();
- Type matchedType = cas.getTypeSystem().getType(
- "org.apache.uima.ruta.type.DebugMatchedRuleMatch");
+ Type matchedType = cas.getTypeSystem()
+ .getType("org.apache.uima.ruta.type.DebugMatchedRuleMatch");
Type ruleApplyType =
cas.getTypeSystem().getType("org.apache.uima.ruta.type.DebugRuleApply");
Type blockApplyType =
cas.getTypeSystem().getType("org.apache.uima.ruta.type.DebugBlockApply");
@@ -155,8 +156,6 @@ public class RutaGEConstraint implements
Double ratioInConstraint = rulesMap.get(key);
if (ratioInConstraint != null) {
results.add(new Double[] { ratioInConstraint, ratioInDocument
});
- } else {
- System.out.println("rule not found!!!: " + key);
}
}
}
@@ -169,13 +168,13 @@ public class RutaGEConstraint implements
removeDebugAnnotations(cas, matchedType, ruleApplyType, blockApplyType);
ae.destroy();
- runCount++;
- printCount++;
- if (printCount == 10) {
- System.out.println(runCount);
- System.out.println("time: " + System.currentTimeMillis());
- printCount = 0;
- }
+// runCount++;
+// printCount++;
+// if (printCount == 10) {
+// System.out.println(runCount);
+// System.out.println("time: " + System.currentTimeMillis());
+// printCount = 0;
+// }
// calculate cosinus similarity for result values:
return EvaluationMeasures.cosine(results);
@@ -201,10 +200,12 @@ public class RutaGEConstraint implements
}
}
+ @Override
public String getDescription() {
return this.description;
}
+ @Override
public void setDescription(String description) {
this.description = description;
}
@@ -248,10 +249,12 @@ public class RutaGEConstraint implements
return rulesMap;
}
+ @Override
public String getData() {
return constraintText;
}
+ @Override
public void setData(String data) {
this.constraintText = data;
}
Modified:
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java
(original)
+++
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java
Thu Nov 7 08:27:02 2019
@@ -34,8 +34,8 @@ import org.eclipse.dltk.internal.debug.c
import org.eclipse.jdt.launching.JavaLaunchDelegate;
import org.eclipse.ui.console.IOConsole;
-public class JavaLocalApplicationLaunchConfigurationDelegate extends
JavaLaunchDelegate implements
- ILaunchConfigurationDelegate {
+public class JavaLocalApplicationLaunchConfigurationDelegate extends
JavaLaunchDelegate
+ implements ILaunchConfigurationDelegate {
@Override
public String getVMArguments(ILaunchConfiguration configuration) throws
CoreException {
@@ -45,7 +45,6 @@ public class JavaLocalApplicationLaunchC
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch
launch,
IProgressMonitor monitor) throws CoreException {
- // System.out.println("launching");
IDbgpService dbgpService = null;
try {
dbgpService = DLTKDebugPlugin.getDefault().getDbgpService();
@@ -60,6 +59,7 @@ public class JavaLocalApplicationLaunchC
final RutaSourceLookupDirector l = new RutaSourceLookupDirector();
launch.setSourceLocator(new ISourceLocator() {
+ @Override
public Object getSourceElement(IStackFrame stackFrame) {
Object sourceElement = sourceLocator.getSourceElement(stackFrame);
if (sourceElement != null)
Modified:
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java
(original)
+++
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java
Thu Nov 7 08:27:02 2019
@@ -71,26 +71,31 @@ import org.eclipse.ui.console.MessageCon
import org.eclipse.ui.console.MessageConsoleStream;
import org.xml.sax.SAXException;
-public class RutaInterpreterRunner extends AbstractInterpreterRunner
implements IConfigurableRunner {
+public class RutaInterpreterRunner extends AbstractInterpreterRunner
+ implements IConfigurableRunner {
public static final IRutaInterpreterRunnerConfig DEFAULT_CONFIG = new
IRutaInterpreterRunnerConfig() {
+ @Override
public void adjustRunnerConfiguration(VMRunnerConfiguration vconfig,
InterpreterConfig iconfig,
ILaunch launch, IJavaProject project) {
- System.out.println("adjust runner");
}
+ @Override
public String[] computeClassPath(InterpreterConfig config, ILaunch launch,
IJavaProject project)
throws Exception {
return RutaInterpreterRunner.getClassPath(project);
}
+ @Override
public String[] getProgramArguments(InterpreterConfig config, ILaunch
launch,
IJavaProject project) {
return new String[0];
}
- public String getRunnerClassName(InterpreterConfig config, ILaunch launch,
IJavaProject project) {
+ @Override
+ public String getRunnerClassName(InterpreterConfig config, ILaunch launch,
+ IJavaProject project) {
return "RutaRunner";
}
@@ -173,8 +178,8 @@ public class RutaInterpreterRunner exten
public static void doRunImpl(InterpreterConfig config, ILaunch launch,
IRutaInterpreterRunnerConfig iconfig, IProgressMonitor monitor)
throws CoreException {
String launchMode = launch.getLaunchMode();
- IScriptProject proj =
AbstractScriptLaunchConfigurationDelegate.getScriptProject(launch
- .getLaunchConfiguration());
+ IScriptProject proj = AbstractScriptLaunchConfigurationDelegate
+ .getScriptProject(launch.getLaunchConfiguration());
IPath projectPath = proj.getResource().getLocation();
IPath inputDirPath =
projectPath.append(RutaProjectUtils.getDefaultInputLocation());
@@ -363,6 +368,7 @@ public class RutaInterpreterRunner exten
return RutaLaunchConfigurationConstants.ID_RUTA_PROCESS_TYPE;
}
+ @Override
public void setRunnerConfig(IRutaInterpreterRunnerConfig config) {
this.config = config;
}
Modified:
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaAutoEditStrategy.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaAutoEditStrategy.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaAutoEditStrategy.java
(original)
+++
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/RutaAutoEditStrategy.java
Thu Nov 7 08:27:02 2019
@@ -23,7 +23,6 @@ import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.apache.uima.ruta.ide.ui.RutaPartitions;
-import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.ui.CodeFormatterConstants;
import org.eclipse.dltk.ui.PreferenceConstants;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -849,9 +848,8 @@ public class RutaAutoEditStrategy extend
/*
* (non-Javadoc)
*
- * @see
- *
org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument
- * , org.eclipse.jface.text.DocumentCommand)
+ * @see
org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.
+ * IDocument , org.eclipse.jface.text.DocumentCommand)
*/
@Override
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
@@ -867,9 +865,6 @@ public class RutaAutoEditStrategy extend
if (indent == null)
super.customizeDocumentCommand(d, c);
else {
- if (DLTKCore.DEBUG) {
- System.err.println("Bug:PTN-9");
- }
c.text = c.text + indent;
}
} catch (BadLocationException e) {
Modified:
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/wizards/RutaProjectCreationWizard.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/wizards/RutaProjectCreationWizard.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/wizards/RutaProjectCreationWizard.java
(original)
+++
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/wizards/RutaProjectCreationWizard.java
Thu Nov 7 08:27:02 2019
@@ -232,7 +232,7 @@ public class RutaProjectCreationWizard e
try {
out = new FileOutputStream(new File(dir, fileName));
} catch (FileNotFoundException e) {
- System.err.println(e);
+ DLTKCore.error(e);
}
if (in != null && out != null) {
copy(in, out);
@@ -246,20 +246,20 @@ public class RutaProjectCreationWizard e
for (int len; (len = fis.read(buffer)) != -1;)
fos.write(buffer, 0, len);
} catch (IOException e) {
- System.err.println(e);
+ DLTKCore.error(e);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
- System.err.println(e);
+ DLTKCore.error(e);
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
- System.err.println(e);
+ DLTKCore.error(e);
}
}
}
@@ -275,6 +275,7 @@ public class RutaProjectCreationWizard e
return res;
}
+ @Override
public void setInitializationData(IConfigurationElement cfig, String
propertyName, Object data) {
fConfigElement = cfig;
}
Modified:
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java
(original)
+++
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java
Thu Nov 7 08:27:02 2019
@@ -114,6 +114,7 @@ public class RutaCompletionEngine extend
return RutaParseUtils.processTypeName(type, token);
}
+ @Override
public void complete(IModuleSource module, int position, int i) {
this.sourceModule = module;
this.actualCompletionPosition = position;
@@ -188,7 +189,7 @@ public class RutaCompletionEngine extend
// }
} catch (Exception e) {
- System.out.println("no completion node found");
+ // ignore
} finally {
this.requestor.endReporting();
}
@@ -242,8 +243,8 @@ public class RutaCompletionEngine extend
if (type == ComponentDeclaration.SCRIPT) {
List<String> scripts = new ArrayList<String>();
- List<IFolder> scriptFolders =
RutaProjectUtils.getAllScriptFolders(sourceModule
- .getModelElement().getScriptProject());
+ List<IFolder> scriptFolders = RutaProjectUtils
+
.getAllScriptFolders(sourceModule.getModelElement().getScriptProject());
for (IFolder folder : scriptFolders) {
try {
scripts.addAll(collectScripts(folder, ""));
@@ -294,8 +295,8 @@ public class RutaCompletionEngine extend
Resource[] resources = getFilesInClasspath(complString, "xml");
for (Resource resource : resources) {
try {
- UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
- new XMLInputSource(resource.getURL()));
+ UIMAFramework.getXMLParser()
+ .parseAnalysisEngineDescription(new
XMLInputSource(resource.getURL()));
String string = getScriptRepresentation(resource, "xml");
if (string != null) {
engines.add(string);
@@ -305,8 +306,8 @@ public class RutaCompletionEngine extend
}
}
if (StringUtils.isAllUpperCase(complString)) {
- List<IFolder> descriptorFolders =
RutaProjectUtils.getAllDescriptorFolders(sourceModule
- .getModelElement().getScriptProject().getProject());
+ List<IFolder> descriptorFolders =
RutaProjectUtils.getAllDescriptorFolders(
+
sourceModule.getModelElement().getScriptProject().getProject());
for (IFolder folder : descriptorFolders) {
try {
engines.addAll(collectEngines(folder, ""));
@@ -324,8 +325,8 @@ public class RutaCompletionEngine extend
Resource[] resources = getFilesInClasspath(complString, "xml");
for (Resource resource : resources) {
try {
- UIMAFramework.getXMLParser().parseTypeSystemDescription(
- new XMLInputSource(resource.getURL()));
+ UIMAFramework.getXMLParser()
+ .parseTypeSystemDescription(new
XMLInputSource(resource.getURL()));
String string = getScriptRepresentation(resource, "xml");
if (string != null) {
tss.add(string);
@@ -336,8 +337,8 @@ public class RutaCompletionEngine extend
}
if (StringUtils.isAllUpperCase(complString)) {
// fallback for camel case
- List<IFolder> descriptorFolders =
RutaProjectUtils.getAllDescriptorFolders(sourceModule
- .getModelElement().getScriptProject().getProject());
+ List<IFolder> descriptorFolders =
RutaProjectUtils.getAllDescriptorFolders(
+
sourceModule.getModelElement().getScriptProject().getProject());
for (IFolder folder : descriptorFolders) {
try {
tss.addAll(collectTypeSystems(folder, ""));
@@ -377,8 +378,8 @@ public class RutaCompletionEngine extend
eachExternalForm = "jar:" + eachExternalForm + "!/";
}
if (externalForm.startsWith(eachExternalForm)) {
- String name = externalForm.substring(eachExternalForm.length(),
externalForm.length()
- - (suffix.length() + 1));
+ String name = externalForm.substring(eachExternalForm.length(),
+ externalForm.length() - (suffix.length() + 1));
name = name.replaceAll("[/]", ".");
return name;
}
@@ -464,9 +465,8 @@ public class RutaCompletionEngine extend
}
}
-
- private Set<String> getTypes(IPath typeSystemDescriptorPath) throws
InvalidXMLException,
- IOException {
+ private Set<String> getTypes(IPath typeSystemDescriptorPath)
+ throws InvalidXMLException, IOException {
Set<String> types = new HashSet<String>();
URL url =
URIUtil.toURI(typeSystemDescriptorPath.toPortableString()).toURL();
try {
@@ -478,12 +478,12 @@ public class RutaCompletionEngine extend
return types;
}
- private Set<String> getTypes(URL resource, ResourceManager resMgr) throws
IOException,
- InvalidXMLException {
+ private Set<String> getTypes(URL resource, ResourceManager resMgr)
+ throws IOException, InvalidXMLException {
Set<String> types = new HashSet<String>();
TypeSystemDescription typeSysDescr = null;
- typeSysDescr = UIMAFramework.getXMLParser().parseTypeSystemDescription(
- new XMLInputSource(resource));
+ typeSysDescr = UIMAFramework.getXMLParser()
+ .parseTypeSystemDescription(new XMLInputSource(resource));
typeSysDescr.resolveImports(resMgr);
for (TypeDescription each : typeSysDescr.getTypes()) {
String name = each.getName();
@@ -523,7 +523,8 @@ public class RutaCompletionEngine extend
if (type == RutaTypeConstants.RUTA_TYPE_AT) {
try {
IPath path =
sourceModule.getModelElement().getResource().getLocation();
- IPath typeSystemDescriptorPath =
RutaProjectUtils.getTypeSystemDescriptorPath(path,
sourceModule.getModelElement().getScriptProject().getProject(), classloader);
+ IPath typeSystemDescriptorPath =
RutaProjectUtils.getTypeSystemDescriptorPath(path,
+
sourceModule.getModelElement().getScriptProject().getProject(), classloader);
types = getTypes(typeSystemDescriptorPath);
} catch (Exception e) {
}
@@ -622,7 +623,6 @@ public class RutaCompletionEngine extend
// }
}
-
private void addProposal(String complString, String string, int kind) {
addProposal(complString, string, string, kind);
}
@@ -661,5 +661,4 @@ public class RutaCompletionEngine extend
}
}
-
}
Modified:
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java
(original)
+++
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java
Thu Nov 7 08:27:02 2019
@@ -55,7 +55,6 @@ public class DLTKRutaErrorReporter {
return;
}
if (re.token == null) {
- System.out.println("Token is null in ErrorReporter");
return;
}
Token token = re.token;
@@ -124,7 +123,6 @@ public class DLTKRutaErrorReporter {
if (!problems.contains(defaultProblem)) {
reporter.reportProblem(defaultProblem);
problems.add(defaultProblem);
- System.out.println(messages[0] + " ### line " + re.token.getLine());
}
}
}
@@ -176,7 +174,6 @@ public class DLTKRutaErrorReporter {
return;
}
if (re.token == null) {
- System.out.println("Token is null in ErrorReporter");
return;
}
Token token = re.token;
@@ -217,7 +214,6 @@ public class DLTKRutaErrorReporter {
if (!problems.contains(defaultProblem)) {
reporter.reportProblem(defaultProblem);
problems.add(defaultProblem);
- System.out.println(messages[0] + " ### line " + ec.token.getLine());
}
} else if (re instanceof MismatchedTokenException) {
MismatchedTokenException ec = (MismatchedTokenException) re;
@@ -257,7 +253,6 @@ public class DLTKRutaErrorReporter {
if (!problems.contains(defaultProblem)) {
reporter.reportProblem(defaultProblem);
problems.add(defaultProblem);
- System.out.println(messages[0] + " ### line " + ec.line);
}
} else if (re instanceof FailedPredicateException) {
String[] messages = { "Syntax Error:" + message, message };
@@ -269,13 +264,12 @@ public class DLTKRutaErrorReporter {
int et = convert.getColumn() + convert.getText().length();
// reporter.handle(CompilerOptions.OFFSET, messages, messages,
// st, et);
- DefaultProblem defaultProblem = new DefaultProblem("", "Type not defined
in this script: "
- + convert.getText(), 0, new String[] {},
ProblemSeverities.Warning, st, et,
- re.token.getLine());
+ DefaultProblem defaultProblem = new DefaultProblem("",
+ "Type not defined in this script: " + convert.getText(), 0, new
String[] {},
+ ProblemSeverities.Warning, st, et, re.token.getLine());
if (!problems.contains(defaultProblem)) {
reporter.reportProblem(defaultProblem);
problems.add(defaultProblem);
- System.out.println(messages[0] + " ### line " + re.token.getLine());
}
} else {
String[] messages = { "Syntax Error:" + message, message };
@@ -292,7 +286,6 @@ public class DLTKRutaErrorReporter {
if (!problems.contains(defaultProblem)) {
reporter.reportProblem(defaultProblem);
problems.add(defaultProblem);
- System.out.println(messages[0] + " ### line " + re.token.getLine());
}
}
// } catch (CoreException e) {
Modified:
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java
(original)
+++
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java
Thu Nov 7 08:27:02 2019
@@ -57,7 +57,6 @@ public class GlobalCASSource {
try {
CAS newCas = ae.newCAS();
CAS++;
- System.out.println("####### CAS: " + CAS);
inUsage.add(newCas);
return newCas;
} catch (Exception e) {
Modified:
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java
(original)
+++
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java
Thu Nov 7 08:27:02 2019
@@ -96,7 +96,8 @@ public abstract class TextRulerBasicLear
private Map<String, TextRulerStatisticsCollector> inducedRules = new
TreeMap<String, TextRulerStatisticsCollector>();
public TextRulerBasicLearner(String inputDir, String prePropTMFile, String
tmpDir,
- String[] slotNames, Set<String> filterSet, boolean skip,
TextRulerLearnerDelegate delegate) {
+ String[] slotNames, Set<String> filterSet, boolean skip,
+ TextRulerLearnerDelegate delegate) {
super();
this.preprocessorFile = prePropTMFile;
this.tempDirectory = tmpDir;
@@ -109,10 +110,10 @@ public abstract class TextRulerBasicLear
filterSetWithSlotNames.add(RutaEngine.BASIC_TYPE);
for (String s : slotNames) {
filterSetWithSlotNames.add(s);
- filterSetWithSlotNames.add(TextRulerTarget.getSingleSlotTypeName(
- MLTargetType.SINGLE_LEFT_BOUNDARY, s));
- filterSetWithSlotNames.add(TextRulerTarget.getSingleSlotTypeName(
- MLTargetType.SINGLE_RIGHT_BOUNDARY, s));
+ filterSetWithSlotNames
+
.add(TextRulerTarget.getSingleSlotTypeName(MLTargetType.SINGLE_LEFT_BOUNDARY,
s));
+ filterSetWithSlotNames
+
.add(TextRulerTarget.getSingleSlotTypeName(MLTargetType.SINGLE_RIGHT_BOUNDARY,
s));
}
useDefaultFiltering = true;
@@ -139,6 +140,7 @@ public abstract class TextRulerBasicLear
return false;
}
+ @Override
public AnalysisEngine getAnalysisEngine() {
if (ae == null) {
updateAE();
@@ -172,8 +174,8 @@ public abstract class TextRulerBasicLear
// the FILTERTYPE expression!
String tempRulesFileName = getTempRulesFileName();
IPath path = new Path(tempRulesFileName);
- ae.setConfigParameterValue(RutaEngine.PARAM_MAIN_SCRIPT,
path.removeFileExtension()
- .lastSegment());
+ ae.setConfigParameterValue(RutaEngine.PARAM_MAIN_SCRIPT,
+ path.removeFileExtension().lastSegment());
String portableString = path.removeLastSegments(1).toPortableString();
ae.setConfigParameterValue(RutaEngine.PARAM_SCRIPT_PATHS, new String[] {
portableString });
ae.setConfigParameterValue(RutaEngine.PARAM_ADDITIONAL_SCRIPTS, new
String[0]);
@@ -218,8 +220,9 @@ public abstract class TextRulerBasicLear
missingString = missingString.substring(0, missingString.length() - 2);
}
if (!result) {
- sendStatusUpdateToDelegate("Error: Some Slot- or Helper-Types were not
found in TypeSystem: "
- + missingString, TextRulerLearnerState.ML_ERROR, false);
+ sendStatusUpdateToDelegate(
+ "Error: Some Slot- or Helper-Types were not found in TypeSystem:
" + missingString,
+ TextRulerLearnerState.ML_ERROR, false);
}
return result;
}
@@ -232,6 +235,7 @@ public abstract class TextRulerBasicLear
return dir.mkdir();
}
+ @Override
public void run() {
if (createTempDirIfNeccessary()) {
updateAE();
@@ -283,6 +287,7 @@ public abstract class TextRulerBasicLear
}
}
+ @Override
public CAS loadCAS(String fileName, CAS reuseCAS) {
return TextRulerToolkit.readCASfromXMIFile(fileName, ae, reuseCAS);
}
@@ -322,8 +327,8 @@ public abstract class TextRulerBasicLear
// the code commented out with FALSENEGATIVES
for (TextRulerExample e : testPositives) {
- TextRulerExample coveredExample =
TextRulerToolkit.exampleListContainsAnnotation(
- originalPositives, e.getAnnotation());
+ TextRulerExample coveredExample = TextRulerToolkit
+ .exampleListContainsAnnotation(originalPositives,
e.getAnnotation());
if (coveredExample != null) {
c.addCoveredPositive(coveredExample); // add covered example and
// increment positive
@@ -425,10 +430,8 @@ public abstract class TextRulerBasicLear
for (int ruleIndex = 0; ruleIndex < rules.size(); ruleIndex++) {
TextRulerRule theRule = rules.get(ruleIndex);
String ruleString = theRule.getRuleString();
- System.out.println("testing: " + ruleString);
if (inducedRules.containsKey(ruleString)) {
theRule.setCoveringStatistics(inducedRules.get(ruleString));
- System.out.println("skipped with " + inducedRules.get(ruleString));
} else {
TextRulerStatisticsCollector sumC = sums.get(ruleIndex);
for (TextRulerExampleDocument theDoc : sortedDocs) {
@@ -436,7 +439,6 @@ public abstract class TextRulerBasicLear
testRuleOnDocument(theRule, theDoc, sumC, theTestCAS);
double errorRate = sumC.n / Math.max(sumC.p, 1);
if (errorRate > maxErrorRate) {
- System.out.println("stopped:" + sumC);
break;
}
if (shouldAbort())
@@ -471,8 +473,8 @@ public abstract class TextRulerBasicLear
TextRulerStatisticsCollector sumC = sums.get(ruleIndex);
if (TextRulerToolkit.DEBUG && !target.equals(theRule.getTarget())) {
- TextRulerToolkit
- .log("[TextRulerBasicLearner.testRulesOnTrainingsSet] ERROR,
ALL RULES MUST HAVE THE SAME LEARNING TARGET !");
+ TextRulerToolkit.log(
+ "[TextRulerBasicLearner.testRulesOnTrainingsSet] ERROR, ALL
RULES MUST HAVE THE SAME LEARNING TARGET !");
}
document.resetAndFillTestCAS(theTestCAS, target);
testRuleOnDocument(theRule, document, sumC, theTestCAS);
@@ -578,6 +580,7 @@ public abstract class TextRulerBasicLear
return useDefaultFiltering;
}
+ @Override
public CAS getTestCAS() {
// one big memory problem occured as we .reset+.release old CASes and
// created new ones
Modified:
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java
(original)
+++
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java
Thu Nov 7 08:27:02 2019
@@ -34,6 +34,8 @@ import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_engine.AnalysisEngine;
@@ -90,18 +92,20 @@ public class TextRulerToolkit {
public static final String RIGHT_BOUNDARY_EXTENSION = "END";
public static void log(String str) {
- if (LOGGING_ENABLED)
- System.out.println(str);
+ if (LOGGING_ENABLED) {
+ Logger.getLogger(TextRulerToolkit.class.getName()).log(Level.INFO, str);
+ }
}
public static void logIfDebug(String str) {
if (DEBUG)
- log(str);
+ Logger.getLogger(TextRulerToolkit.class.getName()).log(Level.INFO, str);
}
public static void logIf(boolean condition, String str) {
- if (LOGGING_ENABLED && condition)
- System.out.println(str);
+ if (LOGGING_ENABLED && condition) {
+ Logger.getLogger(TextRulerToolkit.class.getName()).log(Level.INFO, str);
+ }
}
public static URL getResourceURL(String name) {
@@ -220,9 +224,6 @@ public class TextRulerToolkit {
TypeSystem ts = aCas.getTypeSystem();
Type slotType = ts.getType(slotName);
FSIterator<AnnotationFS> it =
aCas.getAnnotationIndex(slotType).iterator(true);
- if (!it.isValid()) {
- // System.out.println("##### -> iterator not valid for slots!!");
- }
while (it.isValid()) {
AnnotationFS fs = it.get();
@@ -284,8 +285,8 @@ public class TextRulerToolkit {
return result;
}
- public static List<AnnotationFS> getAnnotationsAfterPosition(CAS aCas, int
position,
- int maxCount, Set<String> filterSet, Type rootType) {
+ public static List<AnnotationFS> getAnnotationsAfterPosition(CAS aCas, int
position, int maxCount,
+ Set<String> filterSet, Type rootType) {
int maxPos = aCas.getDocumentText().length() - 1;
List<AnnotationFS> result = getAnnotationWithinBounds(aCas, position,
maxPos, filterSet,
rootType);
@@ -317,9 +318,9 @@ public class TextRulerToolkit {
if (filterSet != null)
allFilters.addAll(filterSet);
for (; it.isValid(); it.moveToNext()) {
- AnnotationFS fs = (AnnotationFS) it.get();
- if (fs.getBegin() == tokenAnnotation.getBegin()
- && fs.getEnd() == tokenAnnotation.getEnd() &&
fs.getType().equals(tokenType)) {
+ AnnotationFS fs = it.get();
+ if (fs.getBegin() == tokenAnnotation.getBegin() && fs.getEnd() ==
tokenAnnotation.getEnd()
+ && fs.getType().equals(tokenType)) {
leftIt = it;
rightIt = it.copy();
@@ -332,11 +333,10 @@ public class TextRulerToolkit {
leftIt.moveToPrevious(); // leave our token annotation behind us...
// search from the token annotation to the left
for (; leftIt.isValid(); leftIt.moveToPrevious()) {
- AnnotationFS fs = (AnnotationFS) leftIt.get();
+ AnnotationFS fs = leftIt.get();
if (fs.getEnd() <= tokenAnnotation.getBegin())
break; // if that happens we are out of reach and can stop
- if (fs.getBegin() <= tokenAnnotation.getBegin()
- && fs.getEnd() >= tokenAnnotation.getEnd()
+ if (fs.getBegin() <= tokenAnnotation.getBegin() && fs.getEnd() >=
tokenAnnotation.getEnd()
&& !allFilters.contains(fs.getType().getName())
&& !ts.subsumes(rootType, fs.getType()))
result.add(fs);
@@ -346,11 +346,10 @@ public class TextRulerToolkit {
if (rightIt.isValid())
rightIt.moveToNext(); // leave our token annotation behind us...
for (; rightIt.isValid(); rightIt.moveToNext()) {
- AnnotationFS fs = (AnnotationFS) rightIt.get();
+ AnnotationFS fs = rightIt.get();
if (fs.getBegin() >= tokenAnnotation.getEnd())
break; // if that happens we are out of reach and can stop
- if (fs.getBegin() <= tokenAnnotation.getBegin()
- && fs.getEnd() >= tokenAnnotation.getEnd()
+ if (fs.getBegin() <= tokenAnnotation.getBegin() && fs.getEnd() >=
tokenAnnotation.getEnd()
&& !allFilters.contains(fs.getType().getName())
&& !ts.subsumes(rootType, fs.getType()))
result.add(fs);
@@ -412,6 +411,7 @@ public class TextRulerToolkit {
List<TextRulerExample> list, TextRulerAnnotation ann) {
TextRulerExample needle = new TextRulerExample(null, ann, true, null);
int index = Collections.binarySearch(list, needle, new
Comparator<TextRulerExample>() {
+ @Override
public int compare(TextRulerExample o1, TextRulerExample o2) {
TextRulerAnnotation afs1 = o1.getAnnotation();
TextRulerAnnotation afs2 = o2.getAnnotation();
@@ -460,7 +460,6 @@ public class TextRulerToolkit {
return typeName;
}
-
public static synchronized String escapeForRegExp(String aRegexFragment) {
final StringBuilder result = new StringBuilder();
Modified:
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java
(original)
+++
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java
Thu Nov 7 08:27:02 2019
@@ -47,23 +47,22 @@ public class TextRulerPreprocessor {
public String run(String inFolder, String docType, String rutaFile, String
tmpDir,
String[] currentSlotNames, TextRulerPreprocessorDelegate delegate) {
- if(StringUtils.isBlank(inFolder)) {
+ if (StringUtils.isBlank(inFolder)) {
return inFolder;
}
-
+
AnalysisEngineDescription analysisEngineDescription = null;
try {
- analysisEngineDescription = TextRulerToolkit
- .getAnalysisEngineDescription(RutaProjectUtils
-
.getAnalysisEngineDescriptorPath(rutaFile).toPortableString());
+ analysisEngineDescription =
TextRulerToolkit.getAnalysisEngineDescription(
+
RutaProjectUtils.getAnalysisEngineDescriptorPath(rutaFile).toPortableString());
} catch (CoreException e) {
TextRulerPlugin.error(e);
}
- if(analysisEngineDescription == null) {
+ if (analysisEngineDescription == null) {
delegate.preprocessorStatusUpdate(this, "Descriptor is missing. Please
rebuild the project.");
return null;
}
-
+
// we want to reuse these cases, so extend the type system in case a
boundary-based learner is
// called
TextRulerToolkit.addBoundaryTypes(analysisEngineDescription,
currentSlotNames);
@@ -73,6 +72,7 @@ public class TextRulerPreprocessor {
File inputFolder = new File(inFolder);
File outputFolder = new File(tmpDir + docType);
File[] files = inputFolder.listFiles(new FilenameFilter() {
+ @Override
public boolean accept(File dir, String name) {
return (name.endsWith(".xmi"));
}
@@ -96,7 +96,6 @@ public class TextRulerPreprocessor {
delegate.preprocessorStatusUpdate(this,
"Loading input XMI file (" + docType + "): " + file.getName());
cas = TextRulerToolkit.readCASfromXMIFile(file, ae, cas);
- System.out.print("Processing...");
try {
ae.process(cas);
TextRulerToolkit.log(" OK");
Modified:
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPLearner.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPLearner.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPLearner.java
(original)
+++
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPLearner.java
Thu Nov 7 08:27:02 2019
@@ -28,6 +28,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.ConstraintFactory;
@@ -142,7 +144,8 @@ public class KEPLearner extends TextRule
removeBadRules();
long estimatedTime = (System.nanoTime() - startTime) / 1000000000;
- System.out.println(estimatedTime + " seconds needed to learn all rules");
+ Logger.getLogger(getClass().getName()).log(Level.INFO,
+ estimatedTime + " seconds needed to learn all rules");
sendStatusUpdateToDelegate("Done", TextRulerLearnerState.ML_DONE, true);
}
@@ -193,15 +196,13 @@ public class KEPLearner extends TextRule
exampleMap.put(annotation.getType().getName(), list);
}
}
- double aLength = (double) (annotation.getEnd() -
annotation.getBegin());
- lengthMap.put(
- annotation.getType().getName(),
- lengthMap.get(annotation.getType().getName()) == null ?
aLength : lengthMap
- .get(annotation.getType().getName()) + aLength);
- countMap.put(
- annotation.getType().getName(),
- countMap.get(annotation.getType().getName()) == null ? 1 :
countMap.get(annotation
- .getType().getName()) + 1);
+ double aLength = annotation.getEnd() - annotation.getBegin();
+ lengthMap.put(annotation.getType().getName(),
+ lengthMap.get(annotation.getType().getName()) == null ? aLength
+ : lengthMap.get(annotation.getType().getName()) +
aLength);
+ countMap.put(annotation.getType().getName(),
+ countMap.get(annotation.getType().getName()) == null ? 1
+ : countMap.get(annotation.getType().getName()) + 1);
}
}
@@ -213,16 +214,17 @@ public class KEPLearner extends TextRule
}
double exLength = 0;
for (TextRulerExample ex : exampleDocuments.getAllPositiveExamples()) {
- exLength += (double) (ex.getAnnotation().getEnd() -
ex.getAnnotation().getBegin());
+ exLength += ex.getAnnotation().getEnd() - ex.getAnnotation().getBegin();
}
double bestRatio = 0;
Type bestType = null;
for (Type type : result) {
- if ((exLength / lengthMap.get(type.getName()) > bestRatio &&
countMap.get(type.getName()) <= exampleDocuments
- .getAllPositiveExamples().size())
+ if ((exLength / lengthMap.get(type.getName()) > bestRatio
+ && countMap.get(type.getName()) <=
exampleDocuments.getAllPositiveExamples().size())
|| (exLength / lengthMap.get(type.getName()) == bestRatio
- && countMap.get(type.getName()) >
countMap.get(bestType.getName()) && countMap
- .get(type.getName()) <=
exampleDocuments.getAllPositiveExamples().size())) {
+ && countMap.get(type.getName()) >
countMap.get(bestType.getName())
+ && countMap.get(type.getName()) <=
exampleDocuments.getAllPositiveExamples()
+ .size())) {
bestType = type;
bestRatio = exLength / lengthMap.get(type.getName());
}
@@ -235,8 +237,8 @@ public class KEPLearner extends TextRule
private void learnRules(TextRulerTarget target) {
List<KEPRule> ruleList =
this.ruleLists.get(target.getSingleSlotTypeName());
- List<TextRulerExample> coveredExamples = this.coveredExamples.get(target
- .getSingleSlotTypeName());
+ List<TextRulerExample> coveredExamples = this.coveredExamples
+ .get(target.getSingleSlotTypeName());
List<TextRulerExample> positiveExamples =
this.exampleDocuments.getAllPositiveExamples();
for (TextRulerExample e : positiveExamples) {
@@ -261,9 +263,8 @@ public class KEPLearner extends TextRule
private List<KEPRule> makeInFillerRulesForExample(TextRulerExample e) {
sendStatusUpdateToDelegate(
- "Searching for Infiller Rules for "
- + e.getTarget().getSingleSlotTypeName()
-
.substring(e.getTarget().getSingleSlotTypeName().lastIndexOf(".") + 1),
+ "Searching for Infiller Rules for " +
e.getTarget().getSingleSlotTypeName()
+
.substring(e.getTarget().getSingleSlotTypeName().lastIndexOf(".") + 1),
TextRulerLearnerState.ML_RUNNING, false);
Collection<KEPRule> rules = new HashSet<KEPRule>();
@@ -281,10 +282,9 @@ public class KEPLearner extends TextRule
testRulesOnDocumentSet(result, exampleDocuments);
sendStatusUpdateToDelegate(
- "Searching for Infiller Rules for "
- + e.getTarget().getSingleSlotTypeName()
-
.substring(e.getTarget().getSingleSlotTypeName().lastIndexOf(".") + 1)
- + " done", TextRulerLearnerState.ML_RUNNING, true);
+ "Searching for Infiller Rules for " +
e.getTarget().getSingleSlotTypeName().substring(
+ e.getTarget().getSingleSlotTypeName().lastIndexOf(".") +
1) + " done",
+ TextRulerLearnerState.ML_RUNNING, true);
return new ArrayList<KEPRule>(rules);
}
@@ -302,8 +302,8 @@ public class KEPLearner extends TextRule
Collection<KEPRule> expandedRules = new HashSet<KEPRule>();
if (rules.isEmpty()) {
- List<AnnotationFS> seeds = getAnnotationsStartingAt(e.getDocumentCAS(),
e.getAnnotation()
- .getBegin(), e.getAnnotation().getEnd());
+ List<AnnotationFS> seeds = getAnnotationsStartingAt(e.getDocumentCAS(),
+ e.getAnnotation().getBegin(), e.getAnnotation().getEnd());
if (seeds.isEmpty()) {
expanding = false;
}
@@ -351,9 +351,8 @@ public class KEPLearner extends TextRule
private List<KEPRule> getCandidateClassificationRules(TextRulerTarget
target) {
sendStatusUpdateToDelegate(
- "Searching for Candidate Classification Rules for "
- + target.getSingleSlotTypeName().substring(
- target.getSingleSlotTypeName().lastIndexOf(".") +
1),
+ "Searching for Candidate Classification Rules for " +
target.getSingleSlotTypeName()
+ .substring(target.getSingleSlotTypeName().lastIndexOf(".")
+ 1),
TextRulerLearnerState.ML_RUNNING, false);
List<KEPRule> result = new ArrayList<KEPRule>();
List<Type> types =
getTokensInNExamples(exampleDocuments.getAllPositiveExamples(),
@@ -366,9 +365,8 @@ public class KEPLearner extends TextRule
// result = getBestAndOptimalRules(result);
result = addConditions(result, target);
sendStatusUpdateToDelegate(
- "Searching for Candidate Classification Rules for "
- + target.getSingleSlotTypeName().substring(
- target.getSingleSlotTypeName().lastIndexOf(".") +
1) + " done",
+ "Searching for Candidate Classification Rules for " +
target.getSingleSlotTypeName()
+ .substring(target.getSingleSlotTypeName().lastIndexOf(".")
+ 1) + " done",
TextRulerLearnerState.ML_RUNNING, true);
return result;
}
@@ -385,8 +383,8 @@ public class KEPLearner extends TextRule
for (Type type : containedTypes) {
if (!type.getName().equals(ruleItem.getType().getName())
&& !ruleItem.containsAndCondition(type)) {
- result.add(new KEPRule(this,
target).addInFillerItem(ruleItem.copy().addAndCondition(
- new KEPRuleItemCondition(type, Condition.CONTAINS,
false))));
+ result.add(new KEPRule(this,
target).addInFillerItem(ruleItem.copy()
+ .addAndCondition(new KEPRuleItemCondition(type,
Condition.CONTAINS, false))));
}
}
}
@@ -413,9 +411,8 @@ public class KEPLearner extends TextRule
result.addAll(addConditions(toRefine, target));
}
sendStatusUpdateToDelegate(
- "Adding conditions to rules for "
- + target.getSingleSlotTypeName().substring(
- target.getSingleSlotTypeName().lastIndexOf(".") +
1) + " done",
+ "Adding conditions to rules for " + target.getSingleSlotTypeName()
+ .substring(target.getSingleSlotTypeName().lastIndexOf(".")
+ 1) + " done",
TextRulerLearnerState.ML_RUNNING, true);
return result;
}
@@ -424,13 +421,9 @@ public class KEPLearner extends TextRule
if (!baseRules.isEmpty() && !shouldAbort()) {
sendStatusUpdateToDelegate(
"Adding postfillers to rules for "
- + baseRules
- .get(0)
- .getTarget()
- .getSingleSlotTypeName()
- .substring(
-
baseRules.get(0).getTarget().getSingleSlotTypeName()
- .lastIndexOf(".") + 1),
+ + baseRules.get(0).getTarget().getSingleSlotTypeName()
+
.substring(baseRules.get(0).getTarget().getSingleSlotTypeName()
+ .lastIndexOf(".") + 1),
TextRulerLearnerState.ML_RUNNING, true);
} else {
return new ArrayList<KEPRule>();
@@ -445,12 +438,12 @@ public class KEPLearner extends TextRule
if (lastItem != null) {
end = lastItem.getEnd();
}
- List<AnnotationFS> annotations =
getAnnotationsStartingAt(e.getDocumentCAS(), end, e
- .getDocumentCAS().getDocumentText().length());
+ List<AnnotationFS> annotations =
getAnnotationsStartingAt(e.getDocumentCAS(), end,
+ e.getDocumentCAS().getDocumentText().length());
boolean blockBoundaryHit = false;
for (AnnotationFS annotationFS : annotations) {
- if (annotationFS.getType().equals(
-
blocks.get(baseRules.get(0).getTarget().getSingleSlotTypeName()))) {
+ if (annotationFS.getType()
+
.equals(blocks.get(baseRules.get(0).getTarget().getSingleSlotTypeName()))) {
blockBoundaryHit = true;
break;
}
@@ -488,13 +481,10 @@ public class KEPLearner extends TextRule
resultList.addAll(makePreFillers(resultList, changed));
sendStatusUpdateToDelegate(
"Adding postfillers to rules for "
- + baseRules
- .get(0)
- .getTarget()
- .getSingleSlotTypeName()
- .substring(
-
baseRules.get(0).getTarget().getSingleSlotTypeName()
- .lastIndexOf(".") + 1) + " done",
+ + baseRules.get(0).getTarget().getSingleSlotTypeName()
+
.substring(baseRules.get(0).getTarget().getSingleSlotTypeName()
+ .lastIndexOf(".") + 1)
+ + " done",
TextRulerLearnerState.ML_RUNNING, true);
return resultList;
}
@@ -503,13 +493,9 @@ public class KEPLearner extends TextRule
if (!baseRules.isEmpty() && !shouldAbort()) {
sendStatusUpdateToDelegate(
"Adding prefillers to rules for "
- + baseRules
- .get(0)
- .getTarget()
- .getSingleSlotTypeName()
- .substring(
-
baseRules.get(0).getTarget().getSingleSlotTypeName()
- .lastIndexOf(".") + 1),
+ + baseRules.get(0).getTarget().getSingleSlotTypeName()
+
.substring(baseRules.get(0).getTarget().getSingleSlotTypeName()
+ .lastIndexOf(".") + 1),
TextRulerLearnerState.ML_RUNNING, true);
} else {
return new ArrayList<KEPRule>();
@@ -527,8 +513,8 @@ public class KEPLearner extends TextRule
List<AnnotationFS> annotations = getAnnotationsEndingAt(begin,
e.getDocumentCAS());
boolean blockBoundaryHit = false;
for (AnnotationFS annotationFS : annotations) {
- if (annotationFS.getType().equals(
-
blocks.get(baseRules.get(0).getTarget().getSingleSlotTypeName()))) {
+ if (annotationFS.getType()
+
.equals(blocks.get(baseRules.get(0).getTarget().getSingleSlotTypeName()))) {
blockBoundaryHit = true;
break;
}
@@ -566,13 +552,10 @@ public class KEPLearner extends TextRule
sendStatusUpdateToDelegate(
"Adding prefillers to rules for "
- + baseRules
- .get(0)
- .getTarget()
- .getSingleSlotTypeName()
- .substring(
-
baseRules.get(0).getTarget().getSingleSlotTypeName()
- .lastIndexOf(".") + 1) + " done",
+ + baseRules.get(0).getTarget().getSingleSlotTypeName()
+
.substring(baseRules.get(0).getTarget().getSingleSlotTypeName()
+ .lastIndexOf(".") + 1)
+ + " done",
TextRulerLearnerState.ML_RUNNING, true);
return resultList;
}
@@ -584,8 +567,8 @@ public class KEPLearner extends TextRule
&& hasPerfectRules.get(slotNamesWithBoundaries[3 * i + 2])) {
List<KEPRule> list = new ArrayList<KEPRule>();
for (KEPRule kepRule : ruleLists.get(slotNames[i])) {
- List<TextRulerExample> exList = new
ArrayList<TextRulerExample>(kepRule
- .getCoveringStatistics().getCoveredNegativeExamples());
+ List<TextRulerExample> exList = new ArrayList<TextRulerExample>(
+
kepRule.getCoveringStatistics().getCoveredNegativeExamples());
exList.removeAll(getCorrectedExamples(slotNames[i]));
if (exList.size() == 0) {
list.add(kepRule);
@@ -596,8 +579,8 @@ public class KEPLearner extends TextRule
if (!hasPerfectRules.get(slotNamesWithBoundaries[3 * i + 1])) {
List<KEPRule> list = new ArrayList<KEPRule>();
for (KEPRule kepRule : ruleLists.get(slotNamesWithBoundaries[3 * i +
1])) {
- List<TextRulerExample> exList = new
ArrayList<TextRulerExample>(kepRule
- .getCoveringStatistics().getCoveredNegativeExamples());
+ List<TextRulerExample> exList = new ArrayList<TextRulerExample>(
+
kepRule.getCoveringStatistics().getCoveredNegativeExamples());
exList.removeAll(getCorrectedExamples(slotNamesWithBoundaries[3 *
i + 1]));
if (exList.size() == 0) {
list.add(kepRule);
@@ -607,8 +590,8 @@ public class KEPLearner extends TextRule
if (!hasPerfectRules.get(slotNamesWithBoundaries[3 * i + 2])) {
List<KEPRule> list = new ArrayList<KEPRule>();
for (KEPRule kepRule : ruleLists.get(slotNamesWithBoundaries[3 * i +
2])) {
- List<TextRulerExample> exList = new
ArrayList<TextRulerExample>(kepRule
- .getCoveringStatistics().getCoveredNegativeExamples());
+ List<TextRulerExample> exList = new ArrayList<TextRulerExample>(
+
kepRule.getCoveringStatistics().getCoveredNegativeExamples());
exList.removeAll(getCorrectedExamples(slotNamesWithBoundaries[3 *
i + 2]));
if (exList.size() == 0) {
list.add(kepRule);
@@ -621,9 +604,8 @@ public class KEPLearner extends TextRule
private List<KEPRule> makeRemovalRules(TextRulerTarget target) {
sendStatusUpdateToDelegate(
- "Searching for Removal Rules for "
- + target.getSingleSlotTypeName().substring(
- target.getSingleSlotTypeName().lastIndexOf(".") +
1),
+ "Searching for Removal Rules for " + target.getSingleSlotTypeName()
+ .substring(target.getSingleSlotTypeName().lastIndexOf(".")
+ 1),
TextRulerLearnerState.ML_RUNNING, false);
if (!hasFalsePositives(target.getSingleSlotTypeName()))
return new ArrayList<KEPRule>();
@@ -638,18 +620,18 @@ public class KEPLearner extends TextRule
if (!containedTypes.isEmpty()) {
KEPRuleItem containsRuleItem = new KEPRuleItem(targetType);
for (Type type : containedTypes) {
- result.add(new KEPRule(this, target).addInFillerItem(
- containsRuleItem.copy().addAndCondition(
- new KEPRuleItemCondition(type, Condition.CONTAINS,
true)))
+ result.add(new KEPRule(this, target)
+ .addInFillerItem(containsRuleItem.copy()
+ .addAndCondition(new KEPRuleItemCondition(type,
Condition.CONTAINS, true)))
.setCorrectionRule(true));
}
}
if (!notContainedTypes.isEmpty()) {
KEPRuleItem notContainsRuleItem = new KEPRuleItem(targetType);
for (Type type : notContainedTypes) {
- result.add(new KEPRule(this, target).addInFillerItem(
- notContainsRuleItem.copy().addAndCondition(
- new KEPRuleItemCondition(type, Condition.CONTAINS,
false)))
+ result.add(new KEPRule(this, target)
+ .addInFillerItem(notContainsRuleItem.copy()
+ .addAndCondition(new KEPRuleItemCondition(type,
Condition.CONTAINS, false)))
.setCorrectionRule(true));
}
}
@@ -667,14 +649,14 @@ public class KEPLearner extends TextRule
}
result.removeAll(toRemove);
if (!toMerge.isEmpty()) {
- result.add(new KEPRule(this, target).addInFillerItem(
- new
KEPRuleItem(targetType).addConditions(toMerge)).setCorrectionRule(true));
+ result.add(new KEPRule(this, target)
+ .addInFillerItem(new
KEPRuleItem(targetType).addConditions(toMerge))
+ .setCorrectionRule(true));
testCorrectionRules(target);
}
sendStatusUpdateToDelegate(
- "Searching for Removal Rules for "
- + target.getSingleSlotTypeName().substring(
- target.getSingleSlotTypeName().lastIndexOf(".") +
1) + " done",
+ "Searching for Removal Rules for " + target.getSingleSlotTypeName()
+ .substring(target.getSingleSlotTypeName().lastIndexOf(".")
+ 1) + " done",
TextRulerLearnerState.ML_RUNNING, true);
return result;
}
@@ -688,16 +670,16 @@ public class KEPLearner extends TextRule
private List<AnnotationFS> getAnnotationsEndingAt(int end, CAS cas) {
List<AnnotationFS> result = new ArrayList<AnnotationFS>();
- FSIterator<AnnotationFS> it = cas.getAnnotationIndex(
-
cas.getTypeSystem().getType(TextRulerToolkit.RUTA_ALL_TYPE_NAME)).iterator();
+ FSIterator<AnnotationFS> it = cas
+
.getAnnotationIndex(cas.getTypeSystem().getType(TextRulerToolkit.RUTA_ALL_TYPE_NAME))
+ .iterator();
while (it.isValid() && it.get().getBegin() < end) {
it.moveToNext();
}
do
it.moveToPrevious();
- while (it.isValid()
- && (it.get().getBegin() >= end ||
filterSetWithSlotNames.contains(it.get().getType()
- .getName())));
+ while (it.isValid() && (it.get().getBegin() >= end
+ || filterSetWithSlotNames.contains(it.get().getType().getName())));
if (!it.isValid())
return result;
end = it.get().getEnd();
@@ -753,11 +735,11 @@ public class KEPLearner extends TextRule
List<KEPRule> tmpList = new ArrayList<KEPRule>();
List<TextRulerExample> coveredExamples = new ArrayList<TextRulerExample>();
List<TextRulerExample> positiveExamples =
exampleDocuments.getAllPositiveExamples();
- List<TextRulerExample> correctedExamples =
getCorrectedExamples(rules.get(0).getTarget()
- .getSingleSlotTypeName());
+ List<TextRulerExample> correctedExamples = getCorrectedExamples(
+ rules.get(0).getTarget().getSingleSlotTypeName());
for (KEPRule rule : rules) {
- List<TextRulerExample> uncorrectedExamples = new
ArrayList<TextRulerExample>(rule
- .getCoveringStatistics().getCoveredNegativeExamples());
+ List<TextRulerExample> uncorrectedExamples = new
ArrayList<TextRulerExample>(
+ rule.getCoveringStatistics().getCoveredNegativeExamples());
uncorrectedExamples.removeAll(correctedExamples);
if (uncorrectedExamples.size() == 0
&& rule.getCoveringStatistics().getCoveredPositivesCount() > 0)
@@ -774,8 +756,8 @@ public class KEPLearner extends TextRule
List<KEPRule> bestRules = getBestRules(rules);
while (!coveredExamples.containsAll(positiveExamples) &&
!bestRules.isEmpty()) {
KEPRule bestRule = bestRules.get(0);
- if (!coveredExamples.containsAll(bestRule.getCoveringStatistics()
- .getCoveredPositiveExamples())) {
+ if (!coveredExamples
+
.containsAll(bestRule.getCoveringStatistics().getCoveredPositiveExamples())) {
coveredExamples.removeAll(bestRule.getCoveringStatistics().getCoveredPositiveExamples());
coveredExamples.addAll(bestRule.getCoveringStatistics().getCoveredPositiveExamples());
tmpList.add(bestRule);
@@ -790,6 +772,7 @@ public class KEPLearner extends TextRule
if (rules.isEmpty())
return new ArrayList<KEPRule>();
final class AComparator implements Comparator<KEPRule> {
+ @Override
public int compare(KEPRule r1, KEPRule r2) {
if (r1.getCoveringStatistics().getCoveredPositivesCount() <
r2.getCoveringStatistics()
.getCoveredPositivesCount())
@@ -803,8 +786,9 @@ public class KEPLearner extends TextRule
else if (r1.getCoveringStatistics().getCoveredNegativesCount() <
r2.getCoveringStatistics()
.getCoveredNegativesCount())
return -1;
- else if (r1.getPreFiller().size() + r1.getInFiller().size() +
r1.getPostFiller().size() < r2
- .getPreFiller().size() + r2.getInFiller().size() +
r2.getPostFiller().size())
+ else if (r1.getPreFiller().size() + r1.getInFiller().size()
+ + r1.getPostFiller().size() < r2.getPreFiller().size() +
r2.getInFiller().size()
+ + r2.getPostFiller().size())
return -1;
return 0;
}
@@ -818,9 +802,9 @@ public class KEPLearner extends TextRule
KEPRule rule = rules.get(i);
if ((3 * rule.getCoveringStatistics().getCoveredPositivesCount() >= rule
.getCoveringStatistics().getCoveredNegativesCount())
- && (rule.getCoveringStatistics().getCoveredPositivesCount() >=
positiveExamples
- .size() ||
!coveredExamples.containsAll(rule.getCoveringStatistics()
- .getCoveredPositiveExamples()))) {
+ && (rule.getCoveringStatistics().getCoveredPositivesCount() >=
positiveExamples.size()
+ || !coveredExamples.containsAll(
+
rule.getCoveringStatistics().getCoveredPositiveExamples()))) {
result.add(rule);
coveredExamples.addAll(rule.getCoveringStatistics().getCoveredPositiveExamples());
@@ -831,8 +815,8 @@ public class KEPLearner extends TextRule
for (int i = 0; i < rules.size(); i++) {
KEPRule rule = rules.get(i);
if (rule.getCoveringStatistics().getCoveredPositivesCount() >=
positiveExamples.size()
- || !coveredExamples.containsAll(rule.getCoveringStatistics()
- .getCoveredPositiveExamples())) {
+ || !coveredExamples
+
.containsAll(rule.getCoveringStatistics().getCoveredPositiveExamples())) {
result.add(rule);
coveredExamples.addAll(rule.getCoveringStatistics().getCoveredPositiveExamples());
@@ -865,10 +849,10 @@ public class KEPLearner extends TextRule
example.getAnnotation().getBegin(),
example.getAnnotation().getEnd(),
filterSetWithSlotNames, null)) {
if (!filterSetWithSlotNames.contains(a.getType().getName()))
- if (((!countOnlyCoveringTokens) && (a.getBegin() >=
example.getAnnotation().getBegin() && a
- .getEnd() <= example.getAnnotation().getEnd()))
- || (a.getBegin() == example.getAnnotation().getBegin() &&
a.getEnd() == example
- .getAnnotation().getEnd())) {
+ if (((!countOnlyCoveringTokens) && (a.getBegin() >=
example.getAnnotation().getBegin()
+ && a.getEnd() <= example.getAnnotation().getEnd()))
+ || (a.getBegin() == example.getAnnotation().getBegin()
+ && a.getEnd() == example.getAnnotation().getEnd())) {
List<TextRulerExample> list = countMap.get(a.getType().getName());
if (list == null) {
list = new ArrayList<TextRulerExample>();
@@ -906,6 +890,7 @@ public class KEPLearner extends TextRule
return result;
}
+ @Override
public String getResultString() {
StringBuffer ruleStrings = new StringBuffer();
if (slotNamesWithBoundaries == null || slotNamesWithBoundaries.length == 0)
@@ -917,13 +902,12 @@ public class KEPLearner extends TextRule
if (blockType != null
&& !(i > 0 && blocks.get(slotNamesWithBoundaries[i - 1]) != null
&& blocks
.get(slotNamesWithBoundaries[i -
1]).getName().equals(blockType.getName()))) {
- ruleStrings.append("BLOCK(" + blockType.getShortName() + ") " +
blockType.getShortName()
- + "{} { \n");
+ ruleStrings.append(
+ "BLOCK(" + blockType.getShortName() + ") " +
blockType.getShortName() + "{} { \n");
}
if (ruleList == null || ruleList.isEmpty()) {
- if (blockType != null
- && !(i < slotNamesWithBoundaries.length - 1
- && blocks.get(slotNamesWithBoundaries[i + 1]) != null
&& blocks
+ if (blockType != null && !(i < slotNamesWithBoundaries.length - 1
+ && blocks.get(slotNamesWithBoundaries[i + 1]) != null && blocks
.get(slotNamesWithBoundaries[i +
1]).getName().equals(blockType.getName())))
ruleStrings.append("} \n");
continue;
@@ -933,10 +917,9 @@ public class KEPLearner extends TextRule
ruleStrings.append((blockType != null ? "\t" : "") +
rule.getRuleString() + "\t// "
+ rule.getCoveringStatistics() + "\n");
}
- if (blockType != null
- && !(i < slotNamesWithBoundaries.length - 1
- && blocks.get(slotNamesWithBoundaries[i + 1]) != null &&
blocks
- .get(slotNamesWithBoundaries[i +
1]).getName().equals(blockType.getName())))
+ if (blockType != null && !(i < slotNamesWithBoundaries.length - 1
+ && blocks.get(slotNamesWithBoundaries[i + 1]) != null
+ && blocks.get(slotNamesWithBoundaries[i +
1]).getName().equals(blockType.getName())))
ruleStrings.append("}");
ruleStrings.append("\n");
}
@@ -951,11 +934,11 @@ public class KEPLearner extends TextRule
for (KEPRule rule : ruleList) {
if
(slotNamesWithBoundaries[i].contains(TextRulerToolkit.LEFT_BOUNDARY_EXTENSION)
||
slotNamesWithBoundaries[i].contains(TextRulerToolkit.RIGHT_BOUNDARY_EXTENSION))
{
- boundaryCorrectors.append(rule.getRuleString() + "\t// " +
rule.getCoveringStatistics()
- + "\n");
+ boundaryCorrectors
+ .append(rule.getRuleString() + "\t// " +
rule.getCoveringStatistics() + "\n");
} else {
- wholeSlotCorrectors.append(rule.getRuleString() + "\t// " +
rule.getCoveringStatistics()
- + "\n");
+ wholeSlotCorrectors
+ .append(rule.getRuleString() + "\t// " +
rule.getCoveringStatistics() + "\n");
}
}
}
@@ -969,8 +952,8 @@ public class KEPLearner extends TextRule
result.append("// " + slotName + " RULES \n");
Type blockType = blocks.get(slotName);
if (blockType != null) {
- result.append("BLOCK(" + blockType.getShortName() + ") " +
blockType.getShortName()
- + "{} { \n");
+ result.append(
+ "BLOCK(" + blockType.getShortName() + ") " +
blockType.getShortName() + "{} { \n");
}
List<KEPRule> ruleList = this.ruleLists.get(slotName);
if (ruleList != null && !ruleList.isEmpty()) {
@@ -995,12 +978,12 @@ public class KEPLearner extends TextRule
+ blockType.getShortName() + "{} { \n");
}
String shortName = slotName.substring(slotName.lastIndexOf(".") + 1);
- String str = shortName + TextRulerToolkit.LEFT_BOUNDARY_EXTENSION +
"{->MARKONCE("
- + shortName + ",1,3)} ANY*? " + shortName +
TextRulerToolkit.RIGHT_BOUNDARY_EXTENSION
- + ";" + "\n";
+ String str = shortName + TextRulerToolkit.LEFT_BOUNDARY_EXTENSION +
"{->MARKONCE(" + shortName
+ + ",1,3)} ANY*? " + shortName +
TextRulerToolkit.RIGHT_BOUNDARY_EXTENSION + ";"
+ + "\n";
str += shortName + TextRulerToolkit.LEFT_BOUNDARY_EXTENSION + "{IS(" +
shortName
- + TextRulerToolkit.RIGHT_BOUNDARY_EXTENSION + ")->MARKONCE(" +
shortName + ")} "
- + ";" + "\n";
+ + TextRulerToolkit.RIGHT_BOUNDARY_EXTENSION + ")->MARKONCE(" +
shortName + ")} " + ";"
+ + "\n";
result.append(str);
if (blockType != null) {
result.append("}");
@@ -1108,8 +1091,8 @@ public class KEPLearner extends TextRule
private void prepareCASWithBoundaries(CAS cas) {
for (String slotName : slotNames)
- if (!(slotName.contains(TextRulerToolkit.LEFT_BOUNDARY_EXTENSION) ||
slotName
- .contains(TextRulerToolkit.RIGHT_BOUNDARY_EXTENSION)))
+ if (!(slotName.contains(TextRulerToolkit.LEFT_BOUNDARY_EXTENSION)
+ || slotName.contains(TextRulerToolkit.RIGHT_BOUNDARY_EXTENSION)))
TextRulerExampleDocument.createBoundaryAnnotationsForCas(cas,
slotName, filterSet);
}
@@ -1130,6 +1113,7 @@ public class KEPLearner extends TextRule
return true;
}
+ @Override
public void setParameters(Map<String, Object> params) {
if (TextRulerToolkit.DEBUG)
saveParametersToTempFolder(params);
@@ -1163,6 +1147,7 @@ public class KEPLearner extends TextRule
private final FSTypeConstraint c = constraint;
+ @Override
public boolean match(FeatureStructure fs) {
return !c.match(fs);
}
@@ -1179,6 +1164,7 @@ public class KEPLearner extends TextRule
this.cas = cas;
}
+ @Override
public int compare(KEPRule o1, KEPRule o2) {
ArrayList<TextRulerRuleItem> items1 = o1.getInFiller();
items1.addAll(o1.getPostFiller());
Modified:
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPatternSegment.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPatternSegment.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPatternSegment.java
(original)
+++
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPatternSegment.java
Thu Nov 7 08:27:02 2019
@@ -32,13 +32,12 @@ public class RapierPatternSegment {
public void debugOutput() {
TextRulerToolkit.log("\n-------------\nShorterList: ");
- for (TextRulerRuleItem t : shorterPattern)
- System.out.print(t.getStringForRuleString(null, null, 0, 1, 0, 1, 0) + "
");
- TextRulerToolkit.log("");
-
- System.out.print("LongerList: ");
- for (TextRulerRuleItem t : longerPattern)
- System.out.print(t.getStringForRuleString(null, null, 0, 1, 0, 1, 0) + "
");
- TextRulerToolkit.log("");
+ for (TextRulerRuleItem t : shorterPattern) {
+ TextRulerToolkit.log(t.getStringForRuleString(null, null, 0, 1, 0, 1, 0)
+ " ");
+ }
+ TextRulerToolkit.log("LongerList: ");
+ for (TextRulerRuleItem t : longerPattern) {
+ TextRulerToolkit.log(t.getStringForRuleString(null, null, 0, 1, 0, 1, 0)
+ " ");
+ }
}
}
Modified:
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/trabal/TrabalLearner.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/trabal/TrabalLearner.java?rev=1869491&r1=1869490&r2=1869491&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/trabal/TrabalLearner.java
(original)
+++
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/trabal/TrabalLearner.java
Thu Nov 7 08:27:02 2019
@@ -1379,10 +1379,8 @@ public class TrabalLearner extends TextR
counter++;
String ruleString = rule.getRuleString();
String ruleInfo = getRuleInfo(rule);
- System.out.println("testing: " + ruleString);
if (inducedRules.containsKey(ruleString)) {
rule.setCoveringStatistics(inducedRules.get(ruleString));
- System.out.println("skipped with " + inducedRules.get(ruleString));
} else {
for (int i = 0; i < goldDocs.size(); i++) {
TextRulerExampleDocument goldDoc = goldDocs.get(i);
@@ -1402,7 +1400,6 @@ public class TrabalLearner extends TextR
pnorm = 1;
}
if (n / pnorm > maxErrorRate) {
- System.out.println("stopped:" + sumC);
break;
}