You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2019/11/18 12:19:33 UTC
svn commit: r1869967 [10/12] - in /uima/uv3/ruta-v3/trunk: ./
example-projects/ExampleProject/descriptor/
example-projects/ExampleProject/descriptor/uima/ruta/example/
example-projects/ExtensionsExample/ example-projects/GermanNovels/
example-projects/...
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaCompletionEngine.java Mon Nov 18 12:19:31 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/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/DLTKRutaHelper.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/DLTKRutaHelper.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/DLTKRutaHelper.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/DLTKRutaHelper.java Mon Nov 18 12:19:31 2019
@@ -33,10 +33,12 @@ import java.util.Map;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.apache.uima.internal.util.XMLUtils;
import org.apache.uima.ruta.engine.RutaEngine;
import org.apache.uima.ruta.ide.RutaIdeCorePlugin;
-import org.apache.uima.ruta.utils.XmlUtils;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -63,6 +65,7 @@ public class DLTKRutaHelper {
final List elements = new ArrayList();
final BufferedReader input = new BufferedReader(new InputStreamReader(stream));
Thread t = new Thread(new Runnable() {
+ @Override
public void run() {
try {
while (true) {
@@ -369,15 +372,12 @@ public class DLTKRutaHelper {
private static Document getDocument(String text) {
try {
- DocumentBuilder parser = XmlUtils.createDocumentBuilder();
+ DocumentBuilderFactory documentBuilderFactory = XMLUtils.createDocumentBuilderFactory();
+ DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
Document document = parser.parse(new ByteArrayInputStream(text.getBytes()));
return document;
- } catch (IOException e) {
- if (DLTKCore.DEBUG) {
- e.printStackTrace();
- }
- } catch (SAXException e) {
+ } catch (IOException | SAXException | ParserConfigurationException e) {
if (DLTKCore.DEBUG) {
e.printStackTrace();
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/PackagesManager.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/PackagesManager.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/PackagesManager.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/PackagesManager.java Mon Nov 18 12:19:31 2019
@@ -23,9 +23,9 @@ import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -36,8 +36,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
@@ -45,9 +46,10 @@ import javax.xml.transform.TransformerFa
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.apache.commons.io.IOUtils;
+import org.apache.uima.internal.util.XMLUtils;
import org.apache.uima.ruta.ide.RutaIdeCorePlugin;
import org.apache.uima.ruta.ide.core.packages.DLTKRutaHelper.RutaPackage;
-import org.apache.uima.ruta.utils.XmlUtils;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -180,19 +182,14 @@ public class PackagesManager {
File packagesFile = packagesPath.toFile();
if (packagesFile.exists()) {
try {
- DocumentBuilder builder = XmlUtils.createDocumentBuilder();
- Document document = builder.parse(new BufferedInputStream(
- new FileInputStream(packagesFile), 2048));
- populate(document.getDocumentElement());
- } catch (FileNotFoundException e) {
- if (DLTKCore.DEBUG) {
- e.printStackTrace();
- }
- } catch (SAXException e) {
- if (DLTKCore.DEBUG) {
- e.printStackTrace();
+ DocumentBuilderFactory documentBuilderFactory = XMLUtils.createDocumentBuilderFactory();
+ DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
+ try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(packagesFile),
+ 2048)) {
+ Document document = builder.parse(bis);
+ populate(document.getDocumentElement());
}
- } catch (IOException e) {
+ } catch (SAXException | IOException | ParserConfigurationException e) {
if (DLTKCore.DEBUG) {
e.printStackTrace();
}
@@ -203,40 +200,31 @@ public class PackagesManager {
private void save() {
IPath packagesPath = RutaIdeCorePlugin.getDefault().getStateLocation().append(PACKAGES_FILE);
File packagesFile = packagesPath.toFile();
- DocumentBuilder builder;
+
+ OutputStream os = null;
try {
- builder = XmlUtils.createDocumentBuilder();
+ DocumentBuilderFactory documentBuilderFactory = XMLUtils.createDocumentBuilderFactory();
+ DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
Document document = builder.newDocument();
save(document);
- FileOutputStream fos = new FileOutputStream(packagesFile, false);
- BufferedOutputStream bos = new BufferedOutputStream(fos, 2048);
+ os = new BufferedOutputStream(new FileOutputStream(packagesFile, false), 2048);
- TransformerFactory serFactory = TransformerFactory.newInstance();
- serFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
- serFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
- Transformer transformer = serFactory.newTransformer();
+ TransformerFactory transformerFactory = XMLUtils.createTransformerFactory();
+ Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
DOMSource source = new DOMSource(document);
- StreamResult outputTarget = new StreamResult(bos);
+ StreamResult outputTarget = new StreamResult(os);
transformer.transform(source, outputTarget);
- bos.close();
- fos.close();
- } catch (FileNotFoundException e) {
- if (DLTKCore.DEBUG) {
- e.printStackTrace();
- }
- } catch (IOException e) {
- if (DLTKCore.DEBUG) {
- e.printStackTrace();
- }
- } catch (TransformerException e) {
+ } catch (IOException | TransformerException | ParserConfigurationException e) {
if (DLTKCore.DEBUG) {
e.printStackTrace();
}
+ } finally {
+ IOUtils.closeQuietly(os);
}
}
@@ -335,9 +323,6 @@ public class PackagesManager {
return key;
}
- /**
- * Return paths specific only for selected package.
- */
public synchronized IPath[] getPathsForPackage(IInterpreterInstall install, String packageName) {
PackageKey key = makeKey(packageName, getInterpreterKey(install));
if (this.packages.containsKey(key)) {
@@ -461,10 +446,8 @@ public class PackagesManager {
save();
}
- /**
- * Return all packages paths in one call.
- */
- public synchronized IPath[] getPathsForPackages(IInterpreterInstall install, Set packagesInBuild) {
+ public synchronized IPath[] getPathsForPackages(IInterpreterInstall install,
+ Set packagesInBuild) {
StringBuffer buf = new StringBuffer();
String[] pkgs = (String[]) packagesInBuild.toArray(new String[packagesInBuild.size()]);
@@ -528,11 +511,6 @@ public class PackagesManager {
return (IPath[]) result.toArray(new IPath[result.size()]);
}
- /**
- * This method removes all information about specified interpreter.
- *
- * @param install
- */
public synchronized void removeInterprterInfo(IInterpreterInstall install) {
// Remove interpreter to packages set
String interpreterPath = getInterpreterKey(install);
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/RutaCheckBuilder.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/RutaCheckBuilder.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/RutaCheckBuilder.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/packages/RutaCheckBuilder.java Mon Nov 18 12:19:31 2019
@@ -58,8 +58,8 @@ import org.eclipse.dltk.launching.IInter
import org.eclipse.dltk.launching.ScriptRuntime;
import org.eclipse.osgi.util.NLS;
-public class RutaCheckBuilder implements IBuildParticipant, IBuildParticipantExtension,
- IBuildParticipantExtension2 {
+public class RutaCheckBuilder
+ implements IBuildParticipant, IBuildParticipantExtension, IBuildParticipantExtension2 {
private final IScriptProject project;
@@ -89,19 +89,13 @@ public class RutaCheckBuilder implements
}
- /**
- * @param project
- * @throws CoreException
- * @throws IllegalStateException
- * if associated interpreter could not be found
- */
public RutaCheckBuilder(IScriptProject project) throws CoreException, IllegalStateException {
this.project = project;
install = ScriptRuntime.getInterpreterInstall(project);
if (install == null) {
// thrown exception is caught in the RutaPackageCheckerType
- throw new IllegalStateException(NLS.bind(Messages.RutaCheckBuilder_interpreterNotFound,
- project.getElementName()));
+ throw new IllegalStateException(
+ NLS.bind(Messages.RutaCheckBuilder_interpreterNotFound, project.getElementName()));
}
knownPackageNames = manager.getPackageNames(install);
buildpath = getBuildpath(project);
@@ -109,12 +103,13 @@ public class RutaCheckBuilder implements
private int buildType;
+ @Override
public boolean beginBuild(int buildType) {
this.buildType = buildType;
if (buildType != FULL_BUILD) {
// retrieve packages provided by this project
- packageCollector.getPackagesProvided().addAll(
- manager.getInternalPackageNames(install, project));
+ packageCollector.getPackagesProvided()
+ .addAll(manager.getInternalPackageNames(install, project));
}
loadProvidedPackagesFromRequiredProjects();
return true;
@@ -135,13 +130,14 @@ public class RutaCheckBuilder implements
final IPath path = entry.getPath();
final IProject project = workspaceRoot.getProject(path.lastSegment());
if (project.exists()) {
- packageCollector.getPackagesProvided().addAll(
- manager.getInternalPackageNames(install, project));
+ packageCollector.getPackagesProvided()
+ .addAll(manager.getInternalPackageNames(install, project));
}
}
}
}
+ @Override
public void buildExternalModule(IBuildContext context) throws CoreException {
final ModuleDeclaration ast = (ModuleDeclaration) context
.get(IBuildContext.ATTR_MODULE_DECLARATION);
@@ -151,6 +147,7 @@ public class RutaCheckBuilder implements
}
}
+ @Override
public void build(IBuildContext context) throws CoreException {
ModuleDeclaration ast = (ModuleDeclaration) context.get(ModuleDeclaration.class.getName());
if (ast == null) {
@@ -159,13 +156,13 @@ public class RutaCheckBuilder implements
packageCollector.getRequireDirectives().clear();
packageCollector.process(ast);
if (!packageCollector.getRequireDirectives().isEmpty()) {
- resourceToModuleInfos.put(
- context.getSourceModule(),
- new ModuleInfo(context.getProblemReporter(), new ArrayList(packageCollector
- .getRequireDirectives())));
+ resourceToModuleInfos.put(context.getSourceModule(),
+ new ModuleInfo(context.getProblemReporter(),
+ new ArrayList(packageCollector.getRequireDirectives())));
}
}
+ @Override
public void endBuild(IProgressMonitor monitor) {
if (buildType != RECONCILE_BUILD) {
// Save packages provided by the project
@@ -310,6 +307,7 @@ public class RutaCheckBuilder implements
return false;
}
+ @Override
public void prepare(IBuildChange buildChange, IBuildState buildState) throws CoreException {
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/DLTKRutaErrorReporter.java Mon Nov 18 12:19:31 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/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/RutaParseUtils.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/RutaParseUtils.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/RutaParseUtils.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/parser/RutaParseUtils.java Mon Nov 18 12:19:31 2019
@@ -166,12 +166,6 @@ public class RutaParseUtils {
return null;
}
- /**
- * @param token
- * @return (start, end)
- * @throws IllegalArgumentException
- * when token==null or !(token instanceof CommonToken)
- */
public static final int[] getBounds(Token token) throws IllegalArgumentException {
if (token == null) {
throw new IllegalArgumentException();
@@ -184,15 +178,6 @@ public class RutaParseUtils {
return bounds;
}
- /**
- * @param tokenA
- * startToken
- * @param tokenB
- * endToken
- * @return positions of a.start // b.end
- * @throws IllegalArgumentException
- * when some token is null or not instanceof CommonToken
- */
public static final int[] getBounds(Token tokenA, Token tokenB) throws IllegalArgumentException {
if (!((tokenA instanceof CommonToken) && (tokenB instanceof CommonToken || tokenB == null))) {
throw new IllegalArgumentException();
@@ -208,10 +193,6 @@ public class RutaParseUtils {
}
}
- /**
- * @param member
- * @return see {@link RutaTypeConstants}, -1 if not valid
- */
public static final int getTypeOfIModelElement(IMember member) {
int type;
try {
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/AbstractFactory.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/AbstractFactory.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/AbstractFactory.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/AbstractFactory.java Mon Nov 18 12:19:31 2019
@@ -27,36 +27,15 @@ import org.eclipse.dltk.ast.ASTNode;
public abstract class AbstractFactory {
- /**
- * @param token
- * @return (start, end)
- * @throws IllegalArgumentException
- * when token==null or !(token instanceof CommonToken)
- */
protected static final int[] getBounds(Token token) throws IllegalArgumentException {
return RutaParseUtils.getBounds(token);
}
- /**
- * @param tokenA
- * startToken
- * @param tokenB
- * endToken
- * @return positions of a.start // b.end
- * @throws IllegalArgumentException
- * when some token is null or not instanceof CommonToken
- */
protected static final int[] getBounds(Token tokenA, Token tokenB)
throws IllegalArgumentException {
return RutaParseUtils.getBounds(tokenA, tokenB);
}
- /**
- *
- * @param a
- * @param b
- * @return indexarray a.start // b.end
- */
protected static final int[] getBounds(Token a, ASTNode b) {
int[] bounds = { 0, 0 };
if (a == null && b == null) {
@@ -89,13 +68,6 @@ public abstract class AbstractFactory {
return bounds;
}
- /**
- * @param head
- * first element. determines bounds[0].
- * @param astnodeListArray
- * in ascending elements order
- * @return bounds of arguments
- */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected static final int[] getSurroundingBounds(ASTNode head, List... astnodeListArray) {
int bounds[] = { Integer.MAX_VALUE, -1 };
@@ -135,12 +107,6 @@ public abstract class AbstractFactory {
}
}
- /**
- * Applies start/end positions of <code>Token token</code> to <code>Node node</code>
- *
- * @param node
- * @param token
- */
protected static final void setBounds(ASTNode node, Token token) {
if (node == null || token == null) {
return;
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ExpressionFactory.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ExpressionFactory.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ExpressionFactory.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ExpressionFactory.java Mon Nov 18 12:19:31 2019
@@ -36,12 +36,6 @@ import org.eclipse.dltk.ast.references.V
public class ExpressionFactory extends AbstractFactory implements ExpressionConstants {
- /**
- * @param ref
- * @param kind
- * see {@link RutaExpressionConstants}
- * @return instance of VariableReference
- */
private static VariableReference newVariableReference(Token ref, int kind) {
int bounds[] = getBounds(ref);
return new RutaVariableReference(bounds[0], bounds[1], ref.getText(), kind);
@@ -216,12 +210,6 @@ public class ExpressionFactory extends A
return new FloatNumericLiteral(bounds[0], bounds[1], value);
}
- /**
- * Creates (local) NumberVariableReference
- *
- * @param numVarRef
- * @return new VariableReference of Token
- */
public static VariableReference createNumberVariableReference(Token numVarRef) {
return newVariableReference(numVarRef, RutaTypeConstants.RUTA_TYPE_N);
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaAction.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaAction.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaAction.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaAction.java Mon Nov 18 12:19:31 2019
@@ -47,12 +47,6 @@ public class RutaAction extends Expressi
private String label;
- /**
- * @param start
- * @param end
- * @param exprs
- * @param kind
- */
public RutaAction(int start, int end, List<ASTNode> exprs, int kind, String name, int nameStart,
int nameEnd) {
super(start, end);
@@ -67,11 +61,6 @@ public class RutaAction extends Expressi
this.nameEnd = nameEnd;
}
- /**
- * Copy-Constructor
- *
- * @param source
- */
public RutaAction(RutaAction source) {
super(source.sourceStart(), source.sourceEnd());
this.exprs = source.exprs;
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaCondition.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaCondition.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaCondition.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaCondition.java Mon Nov 18 12:19:31 2019
@@ -38,12 +38,6 @@ public class RutaCondition extends Expre
private String name;
- /**
- * @param start
- * @param end
- * @param exprs
- * @param kind
- */
public RutaCondition(int start, int end, List<ASTNode> exprs, int kind, String name,
int nameStart, int nameEnd) {
super(start, end);
@@ -81,6 +75,7 @@ public class RutaCondition extends Expre
return exprs;
}
+ @Override
public String toString() {
return this.getClass().getSimpleName() + " : " + super.toString();
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaExpressionList.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaExpressionList.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaExpressionList.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaExpressionList.java Mon Nov 18 12:19:31 2019
@@ -32,11 +32,6 @@ import org.eclipse.dltk.utils.CorePrinte
public class RutaExpressionList extends Expression {
private List<? extends Expression> expressions;
- /**
- * Statement with bounds from first to last expression.
- *
- * @param expressions
- */
public RutaExpressionList(List<? extends Expression> expressions) {
if (!expressions.isEmpty()) {
// First
@@ -53,13 +48,6 @@ public class RutaExpressionList extends
this.expressions = expressions;
}
- /**
- * Statement with specified bounds and expression list.
- *
- * @param start
- * @param end
- * @param expressions
- */
public RutaExpressionList(int start, int end, List<Expression> expressions) {
super(start, end);
if (expressions == null) {
@@ -111,7 +99,7 @@ public class RutaExpressionList extends
output.formatPrintLn("");
Iterator<? extends Expression> i = this.expressions.iterator();
while (i.hasNext()) {
- ASTNode node = (ASTNode) i.next();
+ ASTNode node = i.next();
node.printNode(output);
output.formatPrintLn(" ");
}
@@ -124,7 +112,7 @@ public class RutaExpressionList extends
if (this.expressions != null) {
Iterator<? extends Expression> i = this.expressions.iterator();
while (i.hasNext()) {
- ASTNode node = (ASTNode) i.next();
+ ASTNode node = i.next();
value += node.toString();
value += " ";
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaFunction.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaFunction.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaFunction.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaFunction.java Mon Nov 18 12:19:31 2019
@@ -37,14 +37,8 @@ public class RutaFunction extends Expres
private String name;
- /**
- * @param start
- * @param end
- * @param exprs
- * @param kind
- */
- public RutaFunction(int start, int end, List<ASTNode> exprs, int kind, String name,
- int nameStart, int nameEnd) {
+ public RutaFunction(int start, int end, List<ASTNode> exprs, int kind, String name, int nameStart,
+ int nameEnd) {
super(start, end);
if (exprs != null) {
this.exprs = exprs;
@@ -57,11 +51,6 @@ public class RutaFunction extends Expres
this.nameEnd = nameEnd;
}
- /**
- * Copy-Constructor
- *
- * @param source
- */
public RutaFunction(RutaFunction source) {
super(source.sourceStart(), source.sourceEnd());
this.exprs = source.exprs;
@@ -94,6 +83,7 @@ public class RutaFunction extends Expres
return exprs;
}
+ @Override
public String toString() {
return this.getClass().getSimpleName() + " : " + super.toString();
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaInnerListExpression.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaInnerListExpression.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaInnerListExpression.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaInnerListExpression.java Mon Nov 18 12:19:31 2019
@@ -25,10 +25,6 @@ import org.eclipse.dltk.ast.expressions.
public class RutaInnerListExpression extends Expression {
private String innerList;
- /**
- * @param start
- * @param end
- */
public RutaInnerListExpression(int start, int end, String inner) {
super(start, end);
this.innerList = inner == null ? "" : inner;
@@ -56,17 +52,10 @@ public class RutaInnerListExpression ext
return RutaExpressionConstants.E_INNERLIST;
}
- /**
- * @param innerList
- * the innerList to set
- */
public void setInnerList(String innerList) {
this.innerList = innerList;
}
- /**
- * @return the innerList
- */
public String getInnerList() {
return innerList;
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaRule.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaRule.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaRule.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaRule.java Mon Nov 18 12:19:31 2019
@@ -32,6 +32,7 @@ public class RutaRule extends RutaStatem
this.id = id;
}
+ @Override
public String toString() {
return this.getClass().getSimpleName() + " : " + super.toString();
}
@@ -39,4 +40,5 @@ public class RutaRule extends RutaStatem
public int getId() {
return id;
}
+
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaStatement.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaStatement.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaStatement.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaStatement.java Mon Nov 18 12:19:31 2019
@@ -31,42 +31,20 @@ import org.eclipse.dltk.ast.statements.S
import org.eclipse.dltk.utils.CorePrinter;
public class RutaStatement extends Statement {
+
private List<Expression> expressions;
- /**
- * Statement with bounds from first to last expression.
- *
- * @param expressions
- */
public RutaStatement(List<Expression> expressions) {
- if (!expressions.isEmpty()) {
- // First
- Expression first = expressions.get(0);
- if (first != null) {
- this.setStart(first.sourceStart());
- }
- // Last
- Expression last = expressions.get(expressions.size() - 1);
- if (last != null) {
- this.setEnd(last.sourceEnd());
- }
- }
- this.expressions = expressions;
+
+ setExpressions(expressions);
}
- /**
- * Statement with specified bounds and expression list.
- *
- * @param start
- * @param end
- * @param expressions
- */
public RutaStatement(int start, int end, List<Expression> expressions) {
super(start, end);
if (expressions == null) {
this.expressions = new ArrayList<Expression>();
} else {
- this.expressions = expressions;
+ setExpressions(expressions);
}
}
@@ -112,7 +90,7 @@ public class RutaStatement extends State
output.formatPrintLn("");
Iterator<Expression> i = this.expressions.iterator();
while (i.hasNext()) {
- ASTNode node = (ASTNode) i.next();
+ ASTNode node = i.next();
node.printNode(output);
output.formatPrintLn(" ");
}
@@ -125,7 +103,7 @@ public class RutaStatement extends State
if (this.expressions != null) {
Iterator<Expression> i = this.expressions.iterator();
while (i.hasNext()) {
- ASTNode node = (ASTNode) i.next();
+ ASTNode node = i.next();
value += node.toString();
value += " ";
}
@@ -136,6 +114,23 @@ public class RutaStatement extends State
public void setExpressions(List<Expression> asList) {
this.expressions = asList;
+ updateBoundaries();
+ }
+
+ private void updateBoundaries() {
+
+ if (expressions != null && !expressions.isEmpty()) {
+ // First
+ Expression first = expressions.get(0);
+ if (first != null) {
+ this.setStart(first.sourceStart());
+ }
+ // Last
+ Expression last = expressions.get(expressions.size() - 1);
+ if (last != null) {
+ this.setEnd(last.sourceEnd());
+ }
+ }
}
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaVariableReference.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaVariableReference.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaVariableReference.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/RutaVariableReference.java Mon Nov 18 12:19:31 2019
@@ -24,13 +24,6 @@ import org.eclipse.dltk.ast.references.V
public class RutaVariableReference extends VariableReference {
private int typeId;
- /**
- * @param start
- * @param end
- * @param name
- * @param typedId
- * raw type id from {@link RutaTypeConstants}
- */
public RutaVariableReference(int start, int end, String name, int typedId) {
super(start, end, name);
this.typeId = typedId;
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ScriptFactory.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ScriptFactory.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ScriptFactory.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ScriptFactory.java Mon Nov 18 12:19:31 2019
@@ -28,8 +28,6 @@ import java.util.Set;
import org.antlr.runtime.Token;
import org.apache.commons.lang3.StringUtils;
-import org.apache.uima.ruta.ide.core.parser.RutaLexer;
-import org.apache.uima.ruta.parser.RutaParser;
import org.eclipse.dltk.ast.ASTNode;
import org.eclipse.dltk.ast.expressions.Expression;
import org.eclipse.dltk.ast.statements.Block;
@@ -79,7 +77,7 @@ public class ScriptFactory extends Abstr
Map<Expression, Map<Expression, Expression>> fa, Token s) {
return createRegExpRule(exprs, fa, s, false);
}
-
+
public RutaRule createRegExpRule(List<Expression> exprs,
Map<Expression, Map<Expression, Expression>> fa, Token s, boolean updateCounter) {
List<Expression> expressions = new ArrayList<Expression>();
@@ -97,7 +95,7 @@ public class ScriptFactory extends Abstr
}
}
RutaRegExpRule rule = new RutaRegExpRule(expressions, fa, idCounter);
- if(updateCounter) {
+ if (updateCounter) {
idCounter++;
}
if (s != null) {
@@ -178,34 +176,12 @@ public class ScriptFactory extends Abstr
return rutaRuleElement;
}
- /**
- * Creates Root-Block.
- *
- * @param declStart
- * @param declEnd
- * @param nameStart
- * @param nameEnd
- * @param string
- * @param res
- * @param block
- * @param packageString
- * @return new RutaScriptBlock
- */
public RutaScriptBlock createScriptBlock(int declStart, int declEnd, int nameStart, int nameEnd,
String string, List<RutaRuleElement> res, Block block, String packageString) {
createRule(new ArrayList<Expression>(), null);
return new RutaScriptBlock(string, packageString, nameStart, nameEnd, declStart, declEnd);
}
- /**
- * Creates Method-Blocks.<br>
- * Please call finalizeScriptBlock afterwards.
- *
- * @param id
- * @param type
- * @param rutaBlock
- * @return RutaBlock
- */
public RutaBlock createScriptBlock(Token id, Token type, RutaBlock rutaBlock) {
boolean forEach = false;
if (type != null) {
@@ -235,14 +211,6 @@ public class ScriptFactory extends Abstr
}
}
- /**
- * Creates an AST element for an external block construct
- *
- * @param type
- * @param parent
- * block
- * @return new external block construct
- */
public RutaBlock createExternalBlock(Token type, RutaBlock parent) {
int[] bounds = getBounds(type);
int[] nameBounds = getBounds(type);
@@ -269,9 +237,6 @@ public class ScriptFactory extends Abstr
block.setEnd(rc != null ? getBounds(rc)[1] : rule.sourceEnd());
}
- /**
- * @param body
- */
private void filterNullObjects(List<?> body) {
if (body == null) {
return;
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/StatementFactory.java Mon Nov 18 12:19:31 2019
@@ -32,12 +32,7 @@ import org.eclipse.dltk.ast.references.S
import org.eclipse.dltk.ast.statements.Statement;
public class StatementFactory extends AbstractFactory {
- /**
- * @param component
- * @param impString - import string
- * @param type - type of import
- * @return new Import-Statement
- */
+
public static RutaImportStatement createImport(ComponentDeclaration component, Token impString,
int type) {
int bounds[] = getBounds(impString, component);
@@ -60,18 +55,19 @@ public class StatementFactory extends Ab
public static Statement createImportType(Token importToken, Token type, ComponentDeclaration ts,
Token alias) {
int bounds[] = getBounds(importToken, type);
- if(ts != null) {
+ if (ts != null) {
bounds = getBounds(importToken, ts);
}
- if(alias != null) {
+ if (alias != null) {
bounds = getBounds(importToken, alias);
}
return new RutaImportTypesStatement(bounds[0], bounds[1], ts, type, null, alias);
}
- public static Statement createImportAllPackagew(Token importToken, ComponentDeclaration ts, Token alias) {
+ public static Statement createImportAllPackagew(Token importToken, ComponentDeclaration ts,
+ Token alias) {
int bounds[] = getBounds(importToken, ts);
- if(alias != null) {
+ if (alias != null) {
bounds = getBounds(importToken, alias);
}
return new RutaImportTypesStatement(bounds[0], bounds[1], ts, null, null, alias);
@@ -80,16 +76,15 @@ public class StatementFactory extends Ab
public static Statement createImportPackage(Token importToken, Token pkg, ComponentDeclaration ts,
Token alias) {
int bounds[] = getBounds(importToken, pkg);
- if(ts != null) {
+ if (ts != null) {
bounds = getBounds(importToken, ts);
}
- if(alias != null) {
+ if (alias != null) {
bounds = getBounds(importToken, alias);
}
return new RutaImportTypesStatement(bounds[0], bounds[1], ts, null, pkg, alias);
}
-
-
+
public static RutaImportStatement createImportScript(ComponentDeclaration dottedId,
Token impString) {
if (dottedId != null) {
@@ -112,29 +107,17 @@ public class StatementFactory extends Ab
return createImport(dottedId, impString, kind);
}
- /**
- * @param pString
- * Antlr-Token "PACKAGE"
- * @param dottedId
- * Antlr-Token (dotted-identifier/id)
- * @return new RutaPackageDeclaration
- */
public static RutaPackageDeclaration createPkgDeclaration(Token dottedId, Token pString) {
int bounds[] = getBounds(pString, dottedId);
int nameBounds[] = new int[2];
if (dottedId != null) {
nameBounds = getBounds(dottedId);
}
- SimpleReference ref = new SimpleReference(nameBounds[0], nameBounds[1], dottedId == null ? ""
- : dottedId.getText());
+ SimpleReference ref = new SimpleReference(nameBounds[0], nameBounds[1],
+ dottedId == null ? "" : dottedId.getText());
return new RutaPackageDeclaration(bounds[0], bounds[1], ref);
}
- /**
- * @param id
- * @param type
- * @return new RutaVariableDeclaration
- */
private static RutaVariableDeclaration createVariable(Token id, Token typeToken, int type) {
return createVariable(id, typeToken, type, null);
}
@@ -150,86 +133,38 @@ public class StatementFactory extends Ab
declBounds[1], ref, type, expr);
}
- /**
- * @param id
- * @param type
- * @return new RutaVariableDeclaration
- */
public static RutaVariableDeclaration createIntVariable(Token id, Token type) {
return createVariable(id, type, RutaTypeConstants.RUTA_TYPE_I);
}
- /**
- * @param id
- * @param type
- * @return new variable
- */
public static Object createFloatVariable(Token id, Token type) {
return createVariable(id, type, RutaTypeConstants.RUTA_TYPE_F);
}
- /**
- * @param id
- * @param type
- * @return new RutaVariableDeclaration
- */
public static RutaVariableDeclaration createDoubleVariable(Token id, Token type) {
return createVariable(id, type, RutaTypeConstants.RUTA_TYPE_D);
}
- /**
- * @param id
- * @param type
- * @return new RutaVariableDeclaration
- */
public static RutaVariableDeclaration createStringVariable(Token id, Token type) {
return createVariable(id, type, RutaTypeConstants.RUTA_TYPE_S);
}
- /**
- * @param id
- * @param type
- * @return new RutaVariableDeclaration
- */
public static RutaVariableDeclaration createBooleanVariable(Token id, Token type) {
return createVariable(id, type, RutaTypeConstants.RUTA_TYPE_B);
}
- /**
- * @param id
- * @param type
- * @return new RutaVariableDeclaration
- */
public static RutaVariableDeclaration createTypeVariable(Token id, Token type) {
return createVariable(id, type, RutaTypeConstants.RUTA_TYPE_AT);
}
- /**
- * @param id
- * @param type
- * @return new RutaVariableDeclaration
- */
public static RutaVariableDeclaration createListVariable(Token id, Token type, Expression expr) {
return createVariable(id, type, RutaTypeConstants.RUTA_TYPE_WL, expr);
}
- /**
- * @param id
- * @param type
- * @return new RutaVariableDeclaration
- */
public static RutaVariableDeclaration createTableVariable(Token id, Token type, Expression expr) {
return createVariable(id, type, RutaTypeConstants.RUTA_TYPE_WT, expr);
}
- /**
- * @param id
- * @param declareToken
- * @param type
- * @param features
- * @return new Declaration
- */
-
public static Declaration createAnnotationType(Token id, Token declareToken, Expression type,
List<RutaFeatureDeclaration> features) {
@@ -277,9 +212,10 @@ public class StatementFactory extends Ab
@SuppressWarnings({ "rawtypes" })
public static Statement createDeclareDeclarationsStatement(Token declareToken, List declarations,
ASTNode parent) {
- return createDeclareDeclarationsStatement(declareToken, declarations, parent, new ArrayList<RutaFeatureDeclaration>(0));
+ return createDeclareDeclarationsStatement(declareToken, declarations, parent,
+ new ArrayList<RutaFeatureDeclaration>(0));
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Statement createDeclareDeclarationsStatement(Token declareToken, List declarations,
ASTNode parent, List<RutaFeatureDeclaration> features) {
@@ -297,14 +233,13 @@ public class StatementFactory extends Ab
int end = decls.get(decls.size() - 1).sourceEnd();
statementBounds[1] = Math.max(statementBounds[1], end);
}
- if(features != null && !features.isEmpty()) {
+ if (features != null && !features.isEmpty()) {
int end = features.get(features.size() - 1).sourceEnd();
statementBounds[1] = Math.max(statementBounds[1], end);
}
- return new RutaDeclareDeclarationsStatement(statementBounds[0], statementBounds[1],
- decls, parent, declBounds[0], declBounds[1], features);
+ return new RutaDeclareDeclarationsStatement(statementBounds[0], statementBounds[1], decls,
+ parent, declBounds[0], declBounds[1], features);
}
-
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Statement createDeclarationsStatement(Token declareToken, List declarations,
@@ -323,11 +258,10 @@ public class StatementFactory extends Ab
int end = decls.get(decls.size() - 1).sourceEnd();
statementBounds[1] = Math.max(statementBounds[1], end);
}
- return new RutaDeclarationsStatement(statementBounds[0], statementBounds[1], declarations,
- init, declBounds[0], declBounds[1]);
+ return new RutaDeclarationsStatement(statementBounds[0], statementBounds[1], declarations, init,
+ declBounds[0], declBounds[1]);
}
-
@SuppressWarnings("rawtypes")
public static Statement createDeclarationsStatement(Token declareToken, List declarations) {
return createDeclarationsStatement(declareToken, declarations, null);
@@ -344,7 +278,8 @@ public class StatementFactory extends Ab
return null;
}
- public static Statement createComposedVariableActionDeclaration(Token id, List<RutaAction> actions) {
+ public static Statement createComposedVariableActionDeclaration(Token id,
+ List<RutaAction> actions) {
return null;
}
@@ -372,17 +307,16 @@ public class StatementFactory extends Ab
public static Statement createMacroStatement(Token kind, Token name, Map<Token, Token> def,
List<? extends Expression> elements) {
- int declBounds[] = getBounds(kind, elements.get(elements.size()-1));
+ int declBounds[] = getBounds(kind, elements.get(elements.size() - 1));
int nameBounds[] = getBounds(name);
- int k = kind.equals("CONDITION") ? RutaTypeConstants.RUTA_TYPE_C : RutaTypeConstants.RUTA_TYPE_A;
+ int k = kind.getText().equals("CONDITION") ? RutaTypeConstants.RUTA_TYPE_C
+ : RutaTypeConstants.RUTA_TYPE_A;
// FieldDeclaration
SimpleReference ref = new RutaVariableReference(nameBounds[0], nameBounds[1], name.getText(),
k);
- RutaExpressionList expr = new RutaExpressionList(elements);
+ RutaExpressionList expr = new RutaExpressionList(elements);
return new RutaMacroDeclaration(name.getText(), nameBounds[0], nameBounds[1], declBounds[0],
declBounds[1], ref, k, def, expr);
}
-
-
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-textruler/pom.xml
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-textruler/pom.xml?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-textruler/pom.xml (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-textruler/pom.xml Mon Nov 18 12:19:31 2019
@@ -131,6 +131,7 @@
<excludes>
<exclude>release.properties</exclude> <!-- release generated artifact -->
<exclude>marker-file-identifying-*</exclude>
+ <exclude>META-INF/MANIFEST.MF</exclude>
<exclude>issuesFixed/**</exclude>
</excludes>
</configuration>
@@ -151,7 +152,7 @@
<instructions>
<Bundle-SymbolicName>org.apache.uima.ruta.textruler;singleton:=true</Bundle-SymbolicName>
<Bundle-Activator>org.apache.uima.ruta.textruler.TextRulerPlugin</Bundle-Activator>
- <Bundle-RequiredExecutionEnvironment>JavaSE-1.7</Bundle-RequiredExecutionEnvironment>
+ <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<_nouses>true</_nouses>
<Export-Package>
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/GlobalCASSource.java Mon Nov 18 12:19:31 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/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerBasicLearner.java Mon Nov 18 12:19:31 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/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerToolkit.java Mon Nov 18 12:19:31 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/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearner.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearner.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearner.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearner.java Mon Nov 18 12:19:31 2019
@@ -48,32 +48,13 @@ public interface TextRulerLearner {
ML_UNDEFINED, ML_INITIALIZING, ML_RUNNING, ML_ERROR, ML_ABORTED, ML_DONE
};
- /**
- * There the magic has to be placed...
- */
void run();
- /**
- * this method gets called from the UI and passes a hashMap with key value coded parameters that
- * your corresponding TextRulerLearnerFactory declared by its getAlgorithmParameters method.
- */
void setParameters(Map<String, Object> params);
- /**
- * If any Ruta-Rules result is available (yet), the system asks your algorithm for it by
- * calling this method.
- */
String getResultString();
- /**
- *
- * @return analysis engine
- */
AnalysisEngine getAnalysisEngine();
- /**
- *
- * @return CAS
- */
CAS getTestCAS();
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearnerFactory.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearnerFactory.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearnerFactory.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearnerFactory.java Mon Nov 18 12:19:31 2019
@@ -30,39 +30,12 @@ import java.util.Set;
*/
public interface TextRulerLearnerFactory {
- /**
- * @param inputFolderPath
- * the input folder path where e.g. example XMIs are located
- * @param additionalFolderPath
- * @param preprocessorTMfile
- * the preprocessing Ruta file (this is important for finding the type system and
- * analysis engine descriptor file)
- * @param tempFolderPath
- * a folder name that you can use as temporary folder (caution: you need to create it if
- * you want to use it!)
- * @param fullSlotTypeNames
- * an array with the slot-names to learn (full qualified UIMA type names)
- * @param filterSet
- * Ruta filter set (full qualified UIMA type names)
- * @param skip
- * @param delegate
- * a delegate that can be notified for status updates and asked for aborting the
- * algorithm
- * @return the algorithm of your class that implements TextRulerLearner
- */
public TextRulerLearner createAlgorithm(String inputFolderPath, String additionalFolderPath,
- String preprocessorTMfile, String tempFolderPath, String[] fullSlotTypeNames,
+ String preprocessorRutaFile, String tempFolderPath, String[] fullSlotTypeNames,
Set<String> filterSet, boolean skip, TextRulerLearnerDelegate delegate);
- /**
- * @return null or an array with MLAlgorithmParameters your TextRulerLearner wants to get from the
- * GUI
- */
public TextRulerLearnerParameter[] getAlgorithmParameters();
- /**
- * @return null or a key value set for the standard values of your algorithm's parameters
- */
public Map<String, Object> getAlgorithmParameterStandardValues();
}
Modified: uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java
URL: http://svn.apache.org/viewvc/uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java?rev=1869967&r1=1869966&r2=1869967&view=diff
==============================================================================
--- uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java (original)
+++ uima/uv3/ruta-v3/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerPreprocessor.java Mon Nov 18 12:19:31 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");