I am a uima ruta newbie. I just want to make some changes in seed.flex file which should effect in our eclipse output. I have done many changes but still the output is working as usual. Tell me how to make that changes effect.
Here's how to modify the SeedLexer implementation:
modify/extend SeedLexer.flex with your regex
download jflex 1.4.3 from http://jflex.de/
start the gui of jflex and generate the java class for SeedLexer.flex
build the complete ruta reactor project
Related
I am trying to implement the package/import mechanism into my DSL.
It works perfectly when I have a single file but not with different files.
Even the 15 Minutes Tutorial doesn't work for me. I don't manage to make it work even by coping/pasting the code from the website. I only modify the grammar file.
I tried to investigate this problem further, but found nothing relevant on the Internet.
I noticed that the resource set contains only the current files edited, not the other files present in the project. To see that, I add this line of code in the validator and the scope provider: println(context.eResource.resourceSet.resources).
From my understanding of how XText works, I expected to get one resource for each file present inside the project.
When I create the project, I usually create a "General Project". But I got the same issue with a Java one.
Here my configuration:
macOS Mojave, v. 10.14.1
Eclipse DSL Tools v. 2018-09 (4.9.0)
Xtext v.2.16.0v20181203-0514
JDK 1.8
Thanks a lot for your help.
As suggested by #ChristianDietrich in his comment, the project build was off. After turning it on, the import works perfectly.
I am completely new to Ruta (and to Java).
I installed Eclipse, Maven plugin and Uima Ruta on my computer. I followed the instructions from the UIMA Ruta Guide and Reference. Eclipse shows I have got UIMA Runtime 2.10.2, UIMA Tools 2.10.2, UIMA Ruta Workbench 2.6.1 and UIMA-AS Deployment Descriptor Editor 2.10.3.
But now it turns out that I cannot write (well, compile/run) a single most simple program using Ruta because something is wrong with the imports.
When I write "PACKAGE uima.ruta.example", a red circle appears saying "The package declaration does not match the project structure" -- even if there is no other line in my program.
When I try to compile and run a simple program on an input file (right click on file > UIMA Ruta > Quick Ruta), nothing happens.
I suppose some important files simply haven't been downloaded onto my computer. When I am exploring the directory where I (think I) installed everything, I see there are loads of different "uima" amd "uimaj" packages in there, but I cannot find any packages called 'ruta' or 'ruta.example' or so.
What should I do? Where can I get the 'ruta' library? Does the 'ruta.example' library really exist or is it used in the book just as an example?
(Actually I would also be happy to receive an answer to the question "Why in God's name should I download an environment, install a plugin for it, install a subplugin for it, create a project for it and adjust its settings before writing some programs, instead of just installing and/or compiling some single stuff and just running my program with it in the command line?", but since such a way has not appeared yet officially (has it?), I suppose there should be some serious reasons for that.)
If you use a declaration like PACKAGE uima.ruta.example; it's also required that you put that file in the matching package (directory). So, if your Ruta file names MyExample.ruta it should be located in script/uima/ruta/example/MyExample.ruta. If the Ruta workbench is installed correctly, and you create a default UIMA Ruta project, then it's possible to execute the Ruta file via the file context menu. No additional resources have to be downloaded.
Don't forget to add example input files into the "input" directory. These will be processed and the result will be placed in the "output" directory.
If you are using the Ruta library in Maven project (In a custom project other then running it through the Ruta workbench of Eclipse) you have to add Ruta as dependency in the pom.xml. All transitive dependencies will be downloaded by the Maven system.
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-core</artifactId>
<version>2.6.1</version>
</dependency>
In our corpus we often find and need to parse data that is alpha-numeric as a single token (for example file hashes, email addresses, etc.) We have created our own ruta-core version by re-working the JFlex definition. Is there a way we can still work with this new version of ruta-core in Workbench?
If you use simple Ruta projects, you would need to replace the ruta.engine plugin with a different jar containing your ruta-core version. The clean way would be to build a complete update site with your version.
You could maybe also set your ruta-core jar in the classpath of your ruta launch configurations.
If you use maven-based projects, you can set the dependency to your version of ruta-core, which should then be used in the launch delegate.
For your use case, I would not use your own version of ruta-core at all. You could simply write your own version of the TokenLexer, as you probably did. Then, you can configure the utilized TokenLexer in the RutaEngine as there is a configuration parameter for setting it. Thus, there is already some functionality to customize the JFlex definition without building your own ruta-core.
DISCLAIMER: I am a developer of UIMA Ruta
This question is not limited to lex and yacc, but how can I add a custom script compiler as part of a project? For example, I have the following files in the project:
grammar.y
grammar.l
test.script
The binary 'script_compiler' will be generated using grammar.y and grammar.l compiled by lex, yacc and g++. And then I want to use that generated script_compiler to compile test.script to generate CompiledScript.java. This file should be compiled along with the rest of the java files in the project. This setting is possible with XCode or make, but is it also possible with Eclipse alone? If not, how about together with Maven plugin?
(I might setup the script compiler as a separate project, but it would be nice if they can be put in the same project so that changes to the grammar files can be applied immediately)
Thanks in advance for your help!
You can add a custom "Builder" from the project properties dialog. This can be an ant script (with an optional target) or any other script or executable.
There are also maven plugins for ant and other scripting languages
If you just want to run an external program in Maven this is what you want: http://mojo.codehaus.org/exec-maven-plugin/ -- you can then run Maven targets from your IDE or command line and it should do the right thing either way.
To integrate with the normal compilation bind the plugin to the "generate-sources" phase and add the location where the Java files are generated to the "sourceRoot" option of the exec plugin. That way the compiler will pick them up.
Ideally you generate the code into a folder "target/generated-sources/MY_SCRIPT_NAME". That is the standard location for generated sources in the Maven world and e.g. IntelliJ IDEA will pick up source files inside of that location. Note that this doesn't work if the files are directly in "target/generated-sources".
The other option is to write your own Maven plugin, which is actually quite easy as well. See e.g. https://github.com/peterbecker/maven-code-generator
I am working on a small webapp and I want to use Groovy to write some unit testing for my app. Most of my coding is done on Eclipse and I really want to run all the unit testing with the graphical test runner within Eclipse (I really like the green bar :) )
Sadly, after 4 hours of try-and-error, I'm still not able to setup properly. I tried to use the Eclipse Junit4 test runner to run a Groovy file with method annotated for testing using #Test. But it keeps complaining NoClassDefFoundException
Anyone can help?
Here is content of my groovy file, named simpleTest.groovy
import org.junit.Test
import static org.junit.Assert.assertEquals
class simpleTest{
#Test
void trial(){
assertEquals 6, 3+3
}
}
Anyone can help?
You might want to give the updated plugin a try, see the the recent blog post for more details. The theme of this alpha release is providing an optimized edit/save/compile/test experience, which seems to be your exact use case.
I have this working in my environment so here is a brief summary of what I have:
In the run dialog under JUnit:
Test Tab: The test class, this must have already been compiled by the Groovy plugin.
Classpath: All of the Jar files from my project as well as the Groovy Libraries library
In Window->Preferences->Java->Build Path
Classpath Variables: GROOVY_ECLIPSE_HOME = the location where the Groovy plugin is installed
That does the trick for me.
Unfortunately, the Groovy Eclipse plugin is pretty horrible at giving actual helpful information to let you know what is going wrong with your setup. I'm going to assume you already did the verification to make sure the plugin is actually building your Groovy files (i.e. doing a sample with no dependencies, checking the properly output directory, etc...) After that, it's a lot of really small configuration verification...I've run into problems where the particular "runner" I'm using in Eclipse (i.e. in the Run menu) doesn't have the write class name defined there or for some reason my project didn't get the JUnit library dependency properly inserted into it.
Ultimately, it can be a configuration headache, but long term you'll end up saving some time and gaining some cool functionality if you can knock it out...
I had faced a similar issue and it was the missing package statement that caused me to have problems. Groovy Eclipse plugin did not complain about it but my class was present in a package. I got the noClassDefError when running the file as a JUnit Test.
Adding the package statement to top of class solved this issue.