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 2015/04/22 22:44:50 UTC
svn commit: r1675496 - in /uima/ruta/trunk:
ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/
ruta-ep-addons/src/main/java/org/apache/uima/ruta/searchStrategy/
ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/searchStrategy/
ruta-ep-ad...
Author: pkluegl
Date: Wed Apr 22 20:44:50 2015
New Revision: 1675496
URL: http://svn.apache.org/r1675496
Log:
UIMA-4287
* avoid usage of default locations in IDE tooling
- some renaming
Modified:
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentSelectComposite.java
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/searchStrategy/DescriptorFolderSearchStrategy.java
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/searchStrategy/TestingSearchStrategy.java
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/util/CASLoader.java
uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/apply/AbstractApplyScriptHandlerJob.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/launching/RutaLaunchConfigurationDelegate.java
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/ExternalTypeHyperlinkDetector.java
uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/RutaCheckerUtils.java
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.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/codeassist/RutaSelectionEngine.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/core/TextRulerWordConstraint.java
uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerController.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/ui/AddRemoveList.java
Modified: uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentSelectComposite.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentSelectComposite.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentSelectComposite.java (original)
+++ uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentSelectComposite.java Wed Apr 22 20:44:50 2015
@@ -34,6 +34,7 @@ import org.apache.uima.ruta.engine.RutaE
import org.apache.uima.ruta.ide.core.builder.RutaProjectUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -516,8 +517,14 @@ public class DocumentSelectComposite ext
File file = new File(string);
if (file.isFile()) {
if (file.getName().endsWith(RutaEngine.SCRIPT_FILE_EXTENSION)) {
- IPath path = Path.fromOSString(string);
- tsLocationText.setText(getTypeSystemDescriptorFromScriptFile(path));
+ String typeSystemDescriptorLocation = "";
+ try {
+ typeSystemDescriptorLocation = RutaProjectUtils.getTypeSystemDescriptorPath(string)
+ .toPortableString();
+ } catch (CoreException e) {
+ RutaAddonsPlugin.error(e);
+ }
+ tsLocationText.setText(typeSystemDescriptorLocation);
} else if (file.getName().endsWith(".xml")) {
tsLocationText.setText(string);
}
@@ -534,24 +541,6 @@ public class DocumentSelectComposite ext
}
- private String getTypeSystemDescriptorFromScriptFile(IPath scriptFilePath) {
- IPath folder = scriptFilePath;
-
- while (!folder.lastSegment().equals(RutaProjectUtils.getDefaultScriptLocation())) {
- folder = folder.removeLastSegments(1);
- }
- IPath relativeTo = scriptFilePath.makeRelativeTo(folder);
- IPath projectPath = folder.removeLastSegments(1);
- String elementName = scriptFilePath.lastSegment();
- int lastIndexOf = elementName.lastIndexOf(RutaEngine.SCRIPT_FILE_EXTENSION);
- if (lastIndexOf != -1) {
- elementName = elementName.substring(0, lastIndexOf);
- }
- IPath descPath = projectPath.append(RutaProjectUtils.getDefaultDescriptorLocation());
- IPath descPackagePath = descPath.append(relativeTo.removeLastSegments(1));
- return descPackagePath.append(elementName + "TypeSystem.xml").toString();
- }
-
private void initImages() {
images = new HashMap<String, Image>();
ImageDescriptor desc;
Modified: uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/searchStrategy/DescriptorFolderSearchStrategy.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/searchStrategy/DescriptorFolderSearchStrategy.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/searchStrategy/DescriptorFolderSearchStrategy.java (original)
+++ uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/searchStrategy/DescriptorFolderSearchStrategy.java Wed Apr 22 20:44:50 2015
@@ -22,6 +22,8 @@ package org.apache.uima.ruta.searchStrat
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
import org.apache.uima.caseditor.ide.TypeSystemLocationPropertyPage;
import org.apache.uima.caseditor.ide.searchstrategy.ITypeSystemSearchStrategy;
@@ -58,11 +60,11 @@ public class DescriptorFolderSearchStrat
IProject project = casFile.getProject();
IFile typeSystemLocation = TypeSystemLocationPropertyPage.getTypeSystemLocation(project);
- if(typeSystemLocation != null && !typeSystemLocation.getName().equals("TypeSystem.xml")) {
+ if (typeSystemLocation != null && !typeSystemLocation.getName().equals("TypeSystem.xml")) {
// do not override the properties!
return null;
}
-
+
try {
IProjectNature nature = project.getNature(RutaNature.NATURE_ID);
if (!(nature instanceof RutaNature)) {
@@ -72,9 +74,14 @@ public class DescriptorFolderSearchStrat
return null;
}
- IFolder folder = project.getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
try {
- List<IFile> list = collectTypeSystems(folder);
+ Set<IFile> set = new TreeSet<>();
+ List<IFolder> descriptorFolders = RutaProjectUtils.getDescriptorFolders(project);
+ for (IFolder folder : descriptorFolders) {
+ set.addAll(collectTypeSystems(folder));
+
+ }
+
ListDialog ld = new ListDialog(Display.getCurrent().getActiveShell());
ld.setContentProvider(new IStructuredContentProvider() {
@@ -97,12 +104,12 @@ public class DescriptorFolderSearchStrat
return ((IFile) element).getName();
}
});
- if (list == null || list.isEmpty()) {
+ if (set == null || set.isEmpty()) {
return null;
}
ld.setTitle("Select Type System Descriptor");
- ld.setInput(list);
+ ld.setInput(set);
ld.open();
if (ld.getResult() != null) {
Modified: uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/searchStrategy/TestingSearchStrategy.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/searchStrategy/TestingSearchStrategy.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/searchStrategy/TestingSearchStrategy.java (original)
+++ uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/searchStrategy/TestingSearchStrategy.java Wed Apr 22 20:44:50 2015
@@ -19,7 +19,10 @@
package org.apache.uima.ruta.testing.searchStrategy;
+import java.util.List;
+
import org.apache.uima.caseditor.ide.searchstrategy.ITypeSystemSearchStrategy;
+import org.apache.uima.ruta.addons.RutaAddonsPlugin;
import org.apache.uima.ruta.ide.core.RutaNature;
import org.apache.uima.ruta.ide.core.builder.RutaProjectUtils;
import org.eclipse.core.resources.IFile;
@@ -45,29 +48,37 @@ public class TestingSearchStrategy imple
}
IFolder testFolder = project.getFolder(RutaProjectUtils.getDefaultTestLocation());
- IFolder descFolder = project.getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
IPath relativeTo = location.makeRelativeTo(testFolder.getLocation());
IPath segments = relativeTo.removeLastSegments(2);
String scriptName = segments.lastSegment();
if(scriptName == null) {
return null;
}
- scriptName += "TypeSystem.xml";
segments = segments.removeLastSegments(1);
- IFolder descPackageFolder = null;
+ String tsName = "";
try {
- descPackageFolder = descFolder.getFolder(segments);
+ tsName = scriptName + RutaProjectUtils.getTypeSystemSuffix(project) + ".xml";
} catch (Exception e) {
return null;
}
- if (descPackageFolder == null || !descPackageFolder.exists()) {
- return null;
+ List<IFolder> descriptorFolders = null;
+ try {
+ descriptorFolders = RutaProjectUtils.getDescriptorFolders(project);
+ } catch (CoreException e) {
+ RutaAddonsPlugin.error(e);
}
- IFile result = descPackageFolder.getFile(scriptName);
- if (result == null || !result.exists()) {
+ if(descriptorFolders == null) {
return null;
}
- return result;
+
+ for (IFolder iFolder : descriptorFolders) {
+ IFile result = iFolder.getFile(tsName);
+ if (result == null || !result.exists()) {
+ return null;
+ }
+ }
+
+ return null;
}
}
Modified: uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java (original)
+++ uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java Wed Apr 22 20:44:50 2015
@@ -157,7 +157,7 @@ public class RerunActionHandler implemen
IPath engineDescriptorPath = null;
IPath typeSystemDescriptorPath = null;
try {
- engineDescriptorPath = RutaProjectUtils.getEngineDescriptorPath(r.getLocation(), project);
+ engineDescriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(r.getLocation(), project);
typeSystemDescriptorPath = RutaProjectUtils.getTypeSystemDescriptorPath(
fScript.getLocation(), project);
} catch (CoreException e) {
@@ -280,7 +280,7 @@ public class RerunActionHandler implemen
}
try {
- IPath descriptorPath = RutaProjectUtils.getEngineDescriptorPath(scriptFile.getLocation(),
+ IPath descriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(scriptFile.getLocation(),
project);
String descriptorAbsolutePath = descriptorPath.toFile().getAbsolutePath();
ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
Modified: uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/util/CASLoader.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/util/CASLoader.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/util/CASLoader.java (original)
+++ uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/util/CASLoader.java Wed Apr 22 20:44:50 2015
@@ -49,7 +49,7 @@ public class CASLoader {
}
try {
- IPath engineDescriptorPath = RutaProjectUtils.getEngineDescriptorPath(r.getLocation(),
+ IPath engineDescriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(r.getLocation(),
r.getProject());
XMLInputSource in = new XMLInputSource(engineDescriptorPath.toPortableString());
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
Modified: uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/apply/AbstractApplyScriptHandlerJob.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/apply/AbstractApplyScriptHandlerJob.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/apply/AbstractApplyScriptHandlerJob.java (original)
+++ uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/utils/apply/AbstractApplyScriptHandlerJob.java Wed Apr 22 20:44:50 2015
@@ -100,7 +100,7 @@ public abstract class AbstractApplyScrip
AnalysisEngine ae = null;
try {
IPath rootPath = RutaProjectUtils.getDescriptorRootPath(scriptFile.getProject());
- IPath descriptorPath = RutaProjectUtils.getEngineDescriptorPath(
+ IPath descriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(
scriptFile.getLocation(), scriptFile.getProject());
XMLInputSource in = new XMLInputSource(descriptorPath.toPortableString());
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
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=1675496&r1=1675495&r2=1675496&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 Wed Apr 22 20:44:50 2015
@@ -179,7 +179,7 @@ public class RutaInterpreterRunner exten
IPath projectPath = proj.getResource().getLocation();
IPath inputDirPath = projectPath.append(RutaProjectUtils.getDefaultInputLocation());
IPath outputDirPath = projectPath.append(RutaProjectUtils.getDefaultOutputLocation());
- String engine = RutaProjectUtils.getEngineDescriptorPath(config.getScriptFilePath(),
+ String engine = RutaProjectUtils.getAnalysisEngineDescriptorPath(config.getScriptFilePath(),
proj.getProject()).toPortableString();
IPath rootPath = RutaProjectUtils.getDescriptorRootPath(proj.getProject());
Modified: uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java (original)
+++ uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java Wed Apr 22 20:44:50 2015
@@ -84,7 +84,7 @@ public class RutaLaunchConfigurationDele
IPath projectPath = proj.getResource().getLocation();
IPath inputDirPath = projectPath.append(RutaProjectUtils.getDefaultInputLocation());
IPath outputDirPath = projectPath.append(RutaProjectUtils.getDefaultOutputLocation());
- String engineDefaultMethod = RutaProjectUtils.getEngineDescriptorPath(member.getLocation(),
+ String engineDefaultMethod = RutaProjectUtils.getAnalysisEngineDescriptorPath(member.getLocation(),
proj.getProject()).toPortableString();
String input = configuration.getAttribute(RutaLaunchConstants.INPUT_FOLDER,
inputDirPath.toPortableString());
Modified: uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/ExternalTypeHyperlinkDetector.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/ExternalTypeHyperlinkDetector.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/ExternalTypeHyperlinkDetector.java (original)
+++ uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/ui/text/ExternalTypeHyperlinkDetector.java Wed Apr 22 20:44:50 2015
@@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.TreeSet;
import org.apache.uima.UIMAFramework;
import org.apache.uima.resource.ResourceManager;
@@ -100,17 +101,19 @@ public class ExternalTypeHyperlinkDetect
Collection<String> importedTypeSystems = parsed.descriptorInfo.getImportedTypeSystems();
List<IHyperlink> result = new ArrayList<IHyperlink>();
for (String tsString : importedTypeSystems) {
- IFolder folder = modelElement.getScriptProject().getProject()
- .getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
String xmlFilePath = tsString.replaceAll("\\.", "/");
xmlFilePath = xmlFilePath.substring(0, xmlFilePath.length()) + ".xml";
- Set<String> types = getTypes(folder, xmlFilePath);
- if (types.contains(nodeText)) {
- IFile iFile = getFile(folder, xmlFilePath);
- IHyperlink link = new ExternalTypeHyperlink(nodeText, wordRegion, iFile, tsString,
- fTextEditor);
- result.add(link);
- }
+ Set<String> types = new TreeSet<String>();
+ List<IFolder> descriptorFolders = RutaProjectUtils.getDescriptorFolders(modelElement.getScriptProject().getProject());
+ for (IFolder eachFolder : descriptorFolders) {
+ types.addAll(getTypes(eachFolder, xmlFilePath));
+ if (types.contains(nodeText)) {
+ IFile iFile = getFile(eachFolder, xmlFilePath);
+ IHyperlink link = new ExternalTypeHyperlink(nodeText, wordRegion, iFile, tsString,
+ fTextEditor);
+ result.add(link);
+ }
+ }
}
if (!result.isEmpty()) {
return result.toArray(new IHyperlink[] {});
Modified: uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/RutaCheckerUtils.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/RutaCheckerUtils.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/RutaCheckerUtils.java (original)
+++ uima/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/RutaCheckerUtils.java Wed Apr 22 20:44:50 2015
@@ -223,56 +223,7 @@ public class RutaCheckerUtils {
return null;
}
- /**
- * @param resourceFilePath
- * absolute full path. i.e.: "org.apache.uima.TestList.txt"
- * @return file.exists
- */
- public static boolean checkRessourceExistence(String resourceFilePath, IScriptProject project) {
- IFolder ddlFolder = project.getProject().getFolder(
- RutaProjectUtils.getDefaultDescriptorLocation());
- final String basicXML = "BasicEngine.xml";
- IFile file = getFile(ddlFolder, basicXML);
- AnalysisEngineDescription aed;
- try {
- URL url = file.getLocationURI().toURL();
- aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(new XMLInputSource(url));
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- ConfigurationParameterSettings configurationParameterSettings = aed.getAnalysisEngineMetaData()
- .getConfigurationParameterSettings();
- String[] paths = (String[]) configurationParameterSettings
- .getParameterValue(RutaEngine.PARAM_RESOURCE_PATHS);
- if (paths == null) {
- IFolder folder = project.getProject().getFolder(
- RutaProjectUtils.getDefaultResourcesLocation());
- String defaultPath = folder.getLocation().toPortableString();
- paths = new String[] { defaultPath };
- }
- for (String string : paths) {
- File iFile = new File(string, resourceFilePath);
- // IFile iFile = getFile(folder, ressourceFilePath);
- if (iFile.exists()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @param xmlFilePath
- * absolute full path. i.e.: "org.apache.uima.myengine" ".xml" will be added.
- * @return file.exists
- */
- public static IFile getEngine(String xmlFilePath, IScriptProject project) {
- IFolder folder = project.getProject()
- .getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
- String fileExtended = xmlFilePath + ".xml";
- return getFile(folder, fileExtended);
- }
public static IFile checkTypeSystemImport(String localPath, IScriptProject project) {
List<IFolder> allDescriptorFolders;
Modified: uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java (original)
+++ uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java Wed Apr 22 20:44:50 2015
@@ -33,10 +33,13 @@ import org.apache.commons.lang3.StringUt
import org.apache.uima.ruta.engine.RutaEngine;
import org.apache.uima.ruta.ide.core.RutaNature;
import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -107,7 +110,7 @@ public class RutaProjectUtils {
return DEFAULT_TYPESYSTEM_SUFFX;
}
- public static IPath getEngineDescriptorPath(IPath scriptPath, IProject project)
+ public static IPath getAnalysisEngineDescriptorPath(IPath scriptPath, IProject project)
throws CoreException {
String analysisEngineSuffix = getAnalysisEngineSuffix(project);
String name = getScriptWithPackage(scriptPath, project);
@@ -119,6 +122,17 @@ public class RutaProjectUtils {
return null;
}
}
+
+ public static IPath getAnalysisEngineDescriptorPath(String scriptLocation) throws CoreException {
+ IPath analysisEngineDescriptorPath;
+ IPath scriptPath = new org.eclipse.core.runtime.Path(scriptLocation);
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot workspaceRoot = workspace.getRoot();
+ IFile fileForLocation = workspaceRoot.getFileForLocation(scriptPath);
+ analysisEngineDescriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(scriptPath,
+ fileForLocation.getProject());
+ return analysisEngineDescriptorPath;
+ }
public static IPath getTypeSystemDescriptorPath(IPath scriptPath, IProject project)
throws CoreException {
@@ -133,7 +147,18 @@ public class RutaProjectUtils {
}
}
- private static String getScriptWithPackage(IPath scriptPath, IProject project)
+ public static IPath getTypeSystemDescriptorPath(String scriptLocation) throws CoreException {
+ IPath analysisEngineDescriptorPath;
+ IPath scriptPath = new org.eclipse.core.runtime.Path(scriptLocation);
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot workspaceRoot = workspace.getRoot();
+ IFile fileForLocation = workspaceRoot.getFileForLocation(scriptPath);
+ analysisEngineDescriptorPath = RutaProjectUtils.getTypeSystemDescriptorPath(scriptPath,
+ fileForLocation.getProject());
+ return analysisEngineDescriptorPath;
+ }
+
+ public static String getScriptWithPackage(IPath scriptPath, IProject project)
throws CoreException {
String name = getModuleName(scriptPath);
IPath packagePath = getPackagePath(scriptPath, project);
@@ -271,30 +296,30 @@ public class RutaProjectUtils {
return result;
}
- public static List<IFolder> getDescriptorFolders(IProject proj) throws CoreException {
+ public static List<IFolder> getDescriptorFolders(IProject project) throws CoreException {
List<IFolder> result = new ArrayList<IFolder>();
- if (!proj.isOpen()) {
+ if (!project.isOpen()) {
return result;
}
- IProjectNature javaNature = proj.getNature(JAVANATURE);
+ IProjectNature javaNature = project.getNature(JAVANATURE);
if (javaNature != null) {
- IJavaProject javaProject = JavaCore.create(proj);
+ IJavaProject javaProject = JavaCore.create(project);
IPath readOutputLocation = javaProject.readOutputLocation();
IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(readOutputLocation);
result.add(folder);
}
- IProjectNature pearNature = proj.getNature("org.apache.uima.pear.UimaNature");
+ IProjectNature pearNature = project.getNature("org.apache.uima.pear.UimaNature");
if (pearNature != null) {
- IFolder findElement = proj.getFolder("desc");
+ IFolder findElement = project.getFolder("desc");
if (findElement != null) {
result.add((IFolder) findElement);
}
}
- IProjectNature rutaNature = proj.getNature(RutaNature.NATURE_ID);
+ IProjectNature rutaNature = project.getNature(RutaNature.NATURE_ID);
if (rutaNature != null) {
// try to access script project
- IScriptProject sp = DLTKCore.create(proj);
+ IScriptProject sp = DLTKCore.create(project);
if (sp != null) {
IBuildpathEntry[] rawBuildpath = sp.getRawBuildpath();
for (IBuildpathEntry each : rawBuildpath) {
@@ -313,7 +338,50 @@ public class RutaProjectUtils {
}
}
if (result.isEmpty()) {
- IFolder findElement = proj.getFolder(getDefaultDescriptorLocation());
+ IFolder findElement = project.getFolder(getDefaultDescriptorLocation());
+ if (findElement != null) {
+ result.add((IFolder) findElement);
+ }
+ }
+ return result;
+ }
+
+ public static List<IFolder> getResourceFolders(IProject project) throws CoreException {
+ List<IFolder> result = new ArrayList<IFolder>();
+ if (!project.isOpen()) {
+ return result;
+ }
+ IProjectNature javaNature = project.getNature(JAVANATURE);
+ if (javaNature != null) {
+ IJavaProject javaProject = JavaCore.create(project);
+ IPath readOutputLocation = javaProject.readOutputLocation();
+ IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(readOutputLocation);
+ result.add(folder);
+ }
+ IProjectNature rutaNature = project.getNature(RutaNature.NATURE_ID);
+ if (rutaNature != null) {
+
+ // try to access script project
+ IScriptProject sp = DLTKCore.create(project);
+ if (sp != null) {
+ IBuildpathEntry[] rawBuildpath = sp.getRawBuildpath();
+ for (IBuildpathEntry each : rawBuildpath) {
+ IPath path = each.getPath();
+ int entryKind = each.getEntryKind();
+ if (entryKind == IBuildpathEntry.BPE_SOURCE) {
+ IBuildpathAttribute[] extraAttributes = each.getExtraAttributes();
+ for (IBuildpathAttribute eachAttr : extraAttributes) {
+ if (eachAttr.getName().equals(BUILDPATH_ATTRIBUTE_RUTA)
+ && eachAttr.getValue().equals(BUILDPATH_ATTRIBUTE_RESOURCES)) {
+ result.add(ResourcesPlugin.getWorkspace().getRoot().getFolder(path));
+ }
+ }
+ }
+ }
+ }
+ }
+ if (result.isEmpty()) {
+ IFolder findElement = project.getFolder(getDefaultResourcesLocation());
if (findElement != null) {
result.add((IFolder) findElement);
}
@@ -332,12 +400,18 @@ public class RutaProjectUtils {
return result;
}
- public static IPath getScriptRootPath(IProject project) {
- IPath projectPath = project.getLocation();
- IPath descPath = projectPath.append(getDefaultScriptLocation());
- return descPath;
- }
+ public static IPath getScriptRootPath(IProject project) throws CoreException {
+ List<IFolder> scriptFolders = getScriptFolders(project);
+ if (scriptFolders != null && !scriptFolders.isEmpty()) {
+ return scriptFolders.get(0).getLocation();
+ } else {
+ IPath projectPath = project.getLocation();
+ IPath descPath = projectPath.append(getDefaultScriptLocation());
+ return descPath;
+ }
+ }
+
public static IPath getPackagePath(IPath scriptIPath, IProject project) throws CoreException {
List<IFolder> scriptFolders = getScriptFolders(project);
URI scriptURI = URIUtil.toURI(scriptIPath);
@@ -441,9 +515,9 @@ public class RutaProjectUtils {
for (IFolder each : descriptorFolders) {
result.add(each.getLocation().toPortableString());
}
- IFolder resourceFolder = project.getFolder(RutaProjectUtils.getDefaultResourcesLocation());
- if (resourceFolder != null && resourceFolder.exists()) {
- result.add(resourceFolder.getLocation().toPortableString());
+ List<IFolder> resourceFolders = RutaProjectUtils.getResourceFolders(project);
+ for (IFolder each : resourceFolders) {
+ result.add(each.getLocation().toPortableString());
}
}
IProjectNature javaNature = project.getNature(RutaProjectUtils.JAVANATURE);
@@ -504,17 +578,14 @@ public class RutaProjectUtils {
}
public static String getDefaultScriptLocation() {
- // TODO restrict usage of this getter and delegate to buildpath
return BUILDPATH_ATTRIBUTE_SCRIPT;
}
public static String getDefaultResourcesLocation() {
- // TODO restrict usage of this getter and delegate to buildpath
return BUILDPATH_ATTRIBUTE_RESOURCES;
}
public static String getDefaultDescriptorLocation() {
- // TODO restrict usage of this getter and delegate to buildpath
return BUILDPATH_ATTRIBUTE_DESCRIPTOR;
}
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=1675496&r1=1675495&r2=1675496&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 Wed Apr 22 20:44:50 2015
@@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUt
import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_component.AnalysisComponent;
import org.apache.uima.resource.ResourceManager;
+import org.apache.uima.resource.impl.ResourceManager_impl;
import org.apache.uima.resource.metadata.TypeDescription;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.ruta.ide.RutaIdeCorePlugin;
@@ -57,6 +58,7 @@ import org.apache.uima.ruta.ide.parser.a
import org.apache.uima.ruta.ide.parser.ast.RutaVariableReference;
import org.apache.uima.util.InvalidXMLException;
import org.apache.uima.util.XMLInputSource;
+import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -475,24 +477,13 @@ public class RutaCompletionEngine extend
}
}
- private Set<String> importTypeSystem(String xmlFilePath, IProject project)
- throws InvalidXMLException, IOException {
-// TODO
- IFolder folder = project.getProject()
- .getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
- xmlFilePath = xmlFilePath.substring(0, xmlFilePath.length() - 5) + "TypeSystem.xml";
- return getTypes(folder, xmlFilePath);
- }
- private Set<String> getTypes(IFolder folder, String filePath) throws InvalidXMLException,
+ private Set<String> getTypes(IPath typeSystemDescriptorPath) throws InvalidXMLException,
IOException {
Set<String> types = new HashSet<String>();
- IFile iFile = getFile(folder, filePath);
- URL url;
+ URL url = URIUtil.toURI(typeSystemDescriptorPath).toURL();
try {
- url = iFile.getLocationURI().toURL();
- ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
- resMgr.setDataPath(folder.getLocation().toPortableString());
+ ResourceManager resMgr = new ResourceManager_impl(classloader);
types = getTypes(url, resMgr);
} catch (MalformedURLException e) {
e.printStackTrace();
@@ -556,12 +547,9 @@ public class RutaCompletionEngine extend
Collection<String> types = new HashSet<String>();
if (type == RutaTypeConstants.RUTA_TYPE_AT) {
try {
- // TODO
-
IPath path = sourceModule.getModelElement().getPath();
- path = path.removeFirstSegments(2);
- types = importTypeSystem(path.toPortableString(), sourceModule.getModelElement()
- .getScriptProject().getProject());
+ IPath typeSystemDescriptorPath = RutaProjectUtils.getTypeSystemDescriptorPath(path, sourceModule.getModelElement().getScriptProject().getProject());
+ types = getTypes(typeSystemDescriptorPath);
} catch (Exception e) {
}
for (String string : types) {
Modified: uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaSelectionEngine.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaSelectionEngine.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaSelectionEngine.java (original)
+++ uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/codeassist/RutaSelectionEngine.java Wed Apr 22 20:44:50 2015
@@ -206,27 +206,6 @@ public class RutaSelectionEngine extends
}
}
- private void referenceEngineCall(String name) {
- // name = "";
- IScriptProject scriptProject = sourceModule.getScriptProject();
- IFile engine = getEngine(name, scriptProject);
- if (engine == null) {
- return;
- }
- results.add(engine);
- // IScriptProject scriptProject = sourceModule.getScriptProject();
- // IPath path = scriptProject.g;
- // path = path.append(name);
- // IModelElement element;
- // try {
- // element = scriptProject.findElement(path);
- // System.out.println(element.exists() + "bla");
- // } catch (ModelException e) {
- // e.printStackTrace();
- // }
- // sourceModule.
- // scriptProject.findType(packageName, name);
- }
public IFile getFile(IFolder folder, String filePath) {
int lastDot = filePath.lastIndexOf('.');
@@ -240,25 +219,6 @@ public class RutaSelectionEngine extends
return folder.getFile(fName);
}
- /**
- * @param xmlFilePath
- * absolute full path. i.e.: "org.apache.uima.myengine" ".xml" will be added.
- * @return file.exists
- */
- public IFile getEngine(String xmlFilePath, IScriptProject project) {
- IFolder folder = project.getProject().getFolder(
- RutaProjectUtils.getDefaultDescriptorLocation());
- IFolder f = folder.getFolder("de.martin");
- boolean b = f.exists();
- // xmlFilePath = xmlFilePath.replace('.', '/');
- String fileExtended = xmlFilePath + ".xml";
- IFile file = getFile(folder, fileExtended);
- if (file.exists()) {
- IOpenable opena = (IOpenable) file.getAdapter(IOpenable.class);
- return file;
- }
- return null;
- }
/**
* @param s
@@ -278,36 +238,6 @@ public class RutaSelectionEngine extends
}
- private void importTypesystem(String sRefName) {
- typesystems.add(sRefName);
- IFolder folder = sourceModule.getScriptProject().getProject()
- .getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
- if (folder != null) {
- int lastDot = sRefName.lastIndexOf('.');
- String fileNameShort = sRefName.substring(lastDot + 1);
- String folderName = sRefName.substring(0, lastDot);
- String fileName = fileNameShort + ".xml";
- IFolder tsFolder = folder.getFolder(folderName);
- if (tsFolder != null) {
- IFile file = tsFolder.getFile(fileName);
- if (file != null) {
- File tsFile = file.getLocation().toFile();
- try {
- TypeSystemDescription typeSystemDescription = UIMAFramework.getXMLParser()
- .parseTypeSystemDescription(new XMLInputSource(tsFile));
- TypeDescription[] types = typeSystemDescription.getTypes();
- for (TypeDescription each : types) {
- impFields.put(each.getName(), null);
- }
- } catch (InvalidXMLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
/**
* @param sRefName
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=1675496&r1=1675495&r2=1675496&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 Wed Apr 22 20:44:50 2015
@@ -46,8 +46,12 @@ import org.apache.uima.ruta.textruler.pr
import org.apache.uima.ruta.textruler.tools.MemoryWatch;
import org.apache.uima.util.FileUtils;
import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -70,7 +74,7 @@ public abstract class TextRulerBasicLear
protected String tempDirectory;
- protected String preprocessorTMFile;
+ protected String preprocessorFile;
protected Set<String> filterSet;
@@ -97,7 +101,7 @@ public abstract class TextRulerBasicLear
public TextRulerBasicLearner(String inputDir, String prePropTMFile, String tmpDir,
String[] slotNames, Set<String> filterSet, boolean skip, TextRulerLearnerDelegate delegate) {
super();
- this.preprocessorTMFile = prePropTMFile;
+ this.preprocessorFile = prePropTMFile;
this.tempDirectory = tmpDir;
this.slotNames = slotNames;
this.inputDirectory = inputDir;
@@ -146,8 +150,15 @@ public abstract class TextRulerBasicLear
}
private void updateAE() {
- String descriptorFile = TextRulerToolkit.getEngineDescriptorFromTMSourceFile(new Path(
- preprocessorTMFile));
+ IPath analysisEngineDescriptorPath = null;
+ try {
+ analysisEngineDescriptorPath = RutaProjectUtils
+ .getAnalysisEngineDescriptorPath(preprocessorFile);
+ } catch (CoreException e1) {
+ sendStatusUpdateToDelegate("Failed to locate descriptor.",
+ TextRulerLearnerState.ML_INITIALIZING, false);
+ }
+ String descriptorFile = analysisEngineDescriptorPath.toPortableString();
sendStatusUpdateToDelegate("loading AE...", TextRulerLearnerState.ML_INITIALIZING, false);
AnalysisEngineDescription description = TextRulerToolkit
@@ -481,7 +492,7 @@ public abstract class TextRulerBasicLear
}
public String getFileHeaderString(boolean complete) {
- return getPackageString() + getTypeSystemImport(complete) + getFilterCommandString()
+ return getPackageString() + getScriptImport(complete) + getFilterCommandString()
+ getUseDynamicAnchoring(complete) + getBoundaryDeclarations(complete);
}
@@ -517,28 +528,32 @@ public abstract class TextRulerBasicLear
}
}
- private String getTypeSystemImport(boolean complete) {
+ private String getScriptImport(boolean complete) {
if (complete) {
- IPath path = Path.fromOSString(preprocessorTMFile);
+ IPath path = Path.fromOSString(preprocessorFile);
IPath removeLastSegments = path.removeLastSegments(1);
IContainer containerForLocation = ResourcesPlugin.getWorkspace().getRoot()
.getContainerForLocation(removeLastSegments);
IProject project = containerForLocation.getProject();
- IPath scriptRootPath = RutaProjectUtils.getScriptRootPath(project);
+ String scriptWithPackage = null;
+ try {
+ scriptWithPackage = RutaProjectUtils.getScriptWithPackage(path, project);
+ } catch (CoreException e) {
+ }
String moduleName = RutaProjectUtils.getModuleName(path);
- IPath makeRelativeTo = path.makeRelativeTo(scriptRootPath);
- String m = makeRelativeTo.removeFileExtension().toPortableString().replaceAll("/", ".");
- String importString = "SCRIPT " + m + ";\n";
- if (!skip) {
- importString += "Document{-> CALL(" + moduleName + ")};\n";
+ if (scriptWithPackage != null) {
+ String importString = "SCRIPT " + scriptWithPackage + ";\n";
+ if (!skip) {
+ importString += "Document{-> CALL(" + moduleName + ")};\n";
+ }
+ return importString;
}
- return importString;
}
return "";
}
public String getPackageString() {
- IPath path = Path.fromOSString(preprocessorTMFile);
+ IPath path = Path.fromOSString(preprocessorFile);
IPath removeLastSegments = path.removeLastSegments(1);
IContainer containerForLocation = ResourcesPlugin.getWorkspace().getRoot()
.getContainerForLocation(removeLastSegments);
@@ -595,7 +610,7 @@ public abstract class TextRulerBasicLear
str += "inputDir: " + inputDirectory;
str += "\ntempDir: " + tempDirectory;
- str += "\npreprocessTMFile: " + preprocessorTMFile;
+ str += "\npreprocessTMFile: " + preprocessorFile;
str += "\n";
for (Entry<String, Object> e : params.entrySet()) {
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=1675496&r1=1675495&r2=1675496&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 Wed Apr 22 20:44:50 2015
@@ -228,13 +228,12 @@ public class TextRulerToolkit {
while (it.isValid()) {
AnnotationFS fs = it.get();
- // quick hack for quantifier bug in TM:
AnnotationFS previous = result.size() > 0 ? result.get(result.size() - 1) : null;
if (previous == null || previous.getBegin() != fs.getBegin()
|| previous.getEnd() != fs.getEnd())
result.add(fs);
else {
- logIfDebug("******** TM QUANTIFIER BUG ?? Multiple annotation: " + fs.getType().getName());
+ logIfDebug("******** QUANTIFIER BUG ?? Multiple annotation: " + fs.getType().getName());
}
it.moveToNext();
}
@@ -248,12 +247,8 @@ public class TextRulerToolkit {
TypeSystem ts = aCas.getTypeSystem();
try {
- // TODO wie in TMs AnnotationRetrieval evtl nicht den subiterator
- // nehmen, da der auf
- // type comparisons basiert, die wir evtl nicht gegeben haben!?
AnnotationFS boundaryAnnotation = aCas.createAnnotation(ts.getType("uima.tcas.Annotation"),
posStart > 0 ? posStart - 1 : 0, posEnd); // TODO ist das
- // richtig so??!!
FSIterator<AnnotationFS> it = aCas.getAnnotationIndex().subiterator(boundaryAnnotation, true,
true);
while (it.isValid()) {
@@ -309,15 +304,15 @@ public class TextRulerToolkit {
}
public static List<AnnotationFS> getOtherAnnotationsOverToken(CAS aCas,
- AnnotationFS tmTokenAnnotation, Set<String> filterSet) {
+ AnnotationFS tokenAnnotation, Set<String> filterSet) {
List<AnnotationFS> result = new ArrayList<AnnotationFS>();
// filter out document annotation!!
FSIterator<AnnotationFS> it = aCas.getAnnotationIndex().iterator();
- Type tokenType = tmTokenAnnotation.getType();
+ Type tokenType = tokenAnnotation.getType();
FSIterator<AnnotationFS> leftIt = null;
FSIterator<AnnotationFS> rightIt = null;
TypeSystem ts = aCas.getTypeSystem();
- Type tmRootType = ts.getType(RUTA_ALL_TYPE_NAME);
+ Type rootType = ts.getType(RUTA_ALL_TYPE_NAME);
Set<String> allFilters = new HashSet<String>();
allFilters.add("uima.tcas.DocumentAnnotation");
allFilters.add(RutaEngine.BASIC_TYPE);
@@ -325,8 +320,8 @@ public class TextRulerToolkit {
allFilters.addAll(filterSet);
for (; it.isValid(); it.moveToNext()) {
AnnotationFS fs = (AnnotationFS) it.get();
- if (fs.getBegin() == tmTokenAnnotation.getBegin()
- && fs.getEnd() == tmTokenAnnotation.getEnd() && fs.getType().equals(tokenType)) {
+ if (fs.getBegin() == tokenAnnotation.getBegin()
+ && fs.getEnd() == tokenAnnotation.getEnd() && fs.getType().equals(tokenType)) {
leftIt = it;
rightIt = it.copy();
@@ -340,12 +335,12 @@ public class TextRulerToolkit {
// search from the token annotation to the left
for (; leftIt.isValid(); leftIt.moveToPrevious()) {
AnnotationFS fs = (AnnotationFS) leftIt.get();
- if (fs.getEnd() <= tmTokenAnnotation.getBegin())
+ if (fs.getEnd() <= tokenAnnotation.getBegin())
break; // if that happens we are out of reach and can stop
- if (fs.getBegin() <= tmTokenAnnotation.getBegin()
- && fs.getEnd() >= tmTokenAnnotation.getEnd()
+ if (fs.getBegin() <= tokenAnnotation.getBegin()
+ && fs.getEnd() >= tokenAnnotation.getEnd()
&& !allFilters.contains(fs.getType().getName())
- && !ts.subsumes(tmRootType, fs.getType()))
+ && !ts.subsumes(rootType, fs.getType()))
result.add(fs);
}
@@ -354,12 +349,12 @@ public class TextRulerToolkit {
rightIt.moveToNext(); // leave our token annotation behind us...
for (; rightIt.isValid(); rightIt.moveToNext()) {
AnnotationFS fs = (AnnotationFS) rightIt.get();
- if (fs.getBegin() >= tmTokenAnnotation.getEnd())
+ if (fs.getBegin() >= tokenAnnotation.getEnd())
break; // if that happens we are out of reach and can stop
- if (fs.getBegin() <= tmTokenAnnotation.getBegin()
- && fs.getEnd() >= tmTokenAnnotation.getEnd()
+ if (fs.getBegin() <= tokenAnnotation.getBegin()
+ && fs.getEnd() >= tokenAnnotation.getEnd()
&& !allFilters.contains(fs.getType().getName())
- && !ts.subsumes(tmRootType, fs.getType()))
+ && !ts.subsumes(rootType, fs.getType()))
result.add(fs);
}
return result;
@@ -467,41 +462,6 @@ public class TextRulerToolkit {
return typeName;
}
- public static synchronized String getEngineDescriptorFromTMSourceFile(IPath scriptFilePath) {
- IPath folder = scriptFilePath;
-
- while (!folder.lastSegment().equals(RutaProjectUtils.getDefaultScriptLocation())) {
- folder = folder.removeLastSegments(1);
- }
- IPath relativeTo = scriptFilePath.makeRelativeTo(folder);
- IPath projectPath = folder.removeLastSegments(1);
- String elementName = scriptFilePath.lastSegment();
- int lastIndexOf = elementName.lastIndexOf(RutaEngine.SCRIPT_FILE_EXTENSION);
- if (lastIndexOf != -1) {
- elementName = elementName.substring(0, lastIndexOf);
- }
- IPath descPath = projectPath.append(RutaProjectUtils.getDefaultDescriptorLocation());
- IPath descPackagePath = descPath.append(relativeTo.removeLastSegments(1));
- return descPackagePath.append(elementName + "Engine.xml").toString();
- }
-
- public static synchronized String getTypeSystemDescriptorFromTMSourceFile(IPath scriptFilePath) {
- IPath folder = scriptFilePath;
-
- while (!folder.lastSegment().equals(RutaProjectUtils.getDefaultScriptLocation())) {
- folder = folder.removeLastSegments(1);
- }
- IPath relativeTo = scriptFilePath.makeRelativeTo(folder);
- IPath projectPath = folder.removeLastSegments(1);
- String elementName = scriptFilePath.lastSegment();
- int lastIndexOf = elementName.lastIndexOf(RutaEngine.SCRIPT_FILE_EXTENSION);
- if (lastIndexOf != -1) {
- elementName = elementName.substring(0, lastIndexOf);
- }
- IPath descPath = projectPath.append(RutaProjectUtils.getDefaultDescriptorLocation());
- IPath descPackagePath = descPath.append(relativeTo.removeLastSegments(1));
- return descPackagePath.append(elementName + "TypeSystem.xml").toString();
- }
public static synchronized String escapeForRegExp(String aRegexFragment) {
final StringBuilder result = new StringBuilder();
@@ -552,10 +512,10 @@ public class TextRulerToolkit {
return result.toString();
}
- public static synchronized String escapeForTMStringParameter(String aTMStringFragment) {
+ public static synchronized String escapeForStringParameter(String stringFragment) {
final StringBuilder result = new StringBuilder();
- final StringCharacterIterator iterator = new StringCharacterIterator(aTMStringFragment);
+ final StringCharacterIterator iterator = new StringCharacterIterator(stringFragment);
char character = iterator.current();
while (character != CharacterIterator.DONE) {
if (character == '"') {
Modified: uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerWordConstraint.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerWordConstraint.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerWordConstraint.java (original)
+++ uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/core/TextRulerWordConstraint.java Wed Apr 22 20:44:50 2015
@@ -97,7 +97,7 @@ public class TextRulerWordConstraint {
@Override
public String toString() {
if (isRegExpConstraint())
- return TextRulerToolkit.escapeForTMStringParameter(TextRulerToolkit
+ return TextRulerToolkit.escapeForStringParameter(TextRulerToolkit
.escapeForRegExp(tokenAnnotation.getCoveredText()));
else
return tokenAnnotation.getType().getShortName();
Modified: uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerController.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerController.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerController.java (original)
+++ uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerController.java Wed Apr 22 20:44:50 2015
@@ -25,11 +25,13 @@ import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
+import org.apache.uima.ruta.ide.core.builder.RutaProjectUtils;
import org.apache.uima.ruta.textruler.TextRulerPlugin;
import org.apache.uima.ruta.textruler.core.TextRulerToolkit;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
@@ -131,7 +133,7 @@ public class TextRulerController {
}
public static boolean start(final String inFolder, final String additionalFolder,
- final String preprocessorTMFile, final String[] slotNames, Set<String> filters,
+ final String preprocessorFile, final String[] slotNames, Set<String> filters,
final TextRulerControllerDelegate delegate, Map<String, Map<String, Object>> algParams,
boolean skipPreprocessing) {
if (isRunning() || enabledAlgorithmsCount() == 0)
@@ -150,10 +152,18 @@ public class TextRulerController {
return false;
}
- if (TextRulerToolkit.getEngineDescriptorFromTMSourceFile(new Path(preprocessorTMFile)).length() == 0)
+ IPath analysisEngineDescriptorPath = null;
+ try {
+ analysisEngineDescriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(preprocessorFile);
+ } catch (CoreException e) {
+ TextRulerPlugin.error(e);
+ }
+
+ if (analysisEngineDescriptorPath == null) {
return false;
+ }
- currentPreprocessorTMFile = preprocessorTMFile;
+ currentPreprocessorTMFile = preprocessorFile;
currentSlotNames = slotNames;
currentFilters = filters;
currentDelegate = delegate;
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=1675496&r1=1675495&r2=1675496&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 Wed Apr 22 20:44:50 2015
@@ -26,9 +26,11 @@ import org.apache.commons.lang3.StringUt
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.cas.CAS;
+import org.apache.uima.ruta.ide.core.builder.RutaProjectUtils;
import org.apache.uima.ruta.textruler.TextRulerPlugin;
import org.apache.uima.ruta.textruler.core.GlobalCASSource;
import org.apache.uima.ruta.textruler.core.TextRulerToolkit;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
/**
@@ -39,20 +41,25 @@ import org.eclipse.core.runtime.Path;
*/
public class TextRulerPreprocessor {
- public String run(String inFolder, String tmFile, String tmpDir, String[] currentSlotNames,
+ public String run(String inFolder, String rutaFile, String tmpDir, String[] currentSlotNames,
TextRulerPreprocessorDelegate delegate) {
- return run(inFolder, "input", tmFile, tmpDir, currentSlotNames, delegate);
+ return run(inFolder, "input", rutaFile, tmpDir, currentSlotNames, delegate);
}
- public String run(String inFolder, String docType, String tmFile, String tmpDir,
+ public String run(String inFolder, String docType, String rutaFile, String tmpDir,
String[] currentSlotNames, TextRulerPreprocessorDelegate delegate) {
if(StringUtils.isBlank(inFolder)) {
return inFolder;
}
- AnalysisEngineDescription analysisEngineDescription = TextRulerToolkit
- .getAnalysisEngineDescription(TextRulerToolkit
- .getEngineDescriptorFromTMSourceFile(new Path(tmFile)));
+ AnalysisEngineDescription analysisEngineDescription = null;
+ try {
+ analysisEngineDescription = TextRulerToolkit
+ .getAnalysisEngineDescription(RutaProjectUtils
+ .getAnalysisEngineDescriptorPath(rutaFile).toPortableString());
+ } catch (CoreException e) {
+ TextRulerPlugin.error(e);
+ }
if(analysisEngineDescription == null) {
delegate.preprocessorStatusUpdate(this, "Descriptor is missing. Please rebuild the project.");
return null;
Modified: uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/AddRemoveList.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/AddRemoveList.java?rev=1675496&r1=1675495&r2=1675496&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/AddRemoveList.java (original)
+++ uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/AddRemoveList.java Wed Apr 22 20:44:50 2015
@@ -31,11 +31,13 @@ import org.apache.commons.lang3.StringUt
import org.apache.uima.UIMAFramework;
import org.apache.uima.resource.metadata.TypeDescription;
import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.ruta.ide.core.builder.RutaProjectUtils;
import org.apache.uima.ruta.textruler.TextRulerPlugin;
import org.apache.uima.ruta.textruler.core.TextRulerToolkit;
import org.apache.uima.util.InvalidXMLException;
import org.apache.uima.util.XMLInputSource;
import org.apache.uima.util.XMLizable;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
@@ -107,8 +109,13 @@ public class AddRemoveList extends Compo
return;
}
Path scriptPath = new Path(preFilePath);
- String defaultTypeSystemDescriptorLocation = TextRulerToolkit
- .getTypeSystemDescriptorFromTMSourceFile(scriptPath);
+
+ String defaultTypeSystemDescriptorLocation = null;
+ try {
+ defaultTypeSystemDescriptorLocation = RutaProjectUtils.getTypeSystemDescriptorPath(scriptPath.toPortableString()).toPortableString();
+ } catch (CoreException e) {
+ TextRulerPlugin.error(e);
+ }
TypeSystemDescription defaultTypeSystemDescription = null;
try {
defaultTypeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription(