Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-5423

Variables in Ruta scripts are not initialized properly by RutaEngine if their script is called by others

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.3.0ruta
    • 2.6.1ruta
    • Ruta
    • None

    Description

      Variables in Ruta scripts are not initialized properly by RutaEngine if their

      script is called by others.

      We found this issue in Ruta 2.3.1, but it’s still in Ruta 2.6.0.

      I attached the sample project TestVariable.zip to this mail.

      Example: script3.ruta


      DECLARE Value(STRING value);

      STRING value;

      W{-> CREATE(Value, "value" = value), ASSIGN(value, W.ct)};


      Creates an annotation "Value" with an empty feature "value".

      The variable "value" stores the word (and is evaluated by other rules – the real use case doesn't matters here).

      Input testfiles:

      input-01.txt: snark

      input-02.txt: cat

      Output after running Ruta with script3.ruta:

      input-01.txt.xmi: Value annotation for "snark" with an empty value (nil)

      input-02.txt.xmi: Value annotation for "cat" with an empty value (nil)

      => works as expected.

      We added two scripts to call finally script3.ruta in the order

      script1 calls script2 => script2 calls script3 => scripts3

      to creates Value annotation.

      (our real project is complex - uses packages ...)

      Now we call script1.ruta on the same input, but the output annotation Value

      contains a wrong value feature for all documents after the first.

      input-01.txt.xmi: Value annotation for "snark" with an empty value (nil)

      input-02.txt.xmi: Value annotation "cat" with value feature "snark" (instead

      of nil as before).

      It seems the variable is not initialized properly if it is defined in a sub-script, which is called by other scripts.

      It doesn't help to initialized the variable in script3, e.g:

      STRING value = "dog"


      The output is unchanged the Value annotation return the stored variable,

      which was set by script3.ruta while processing the first input file.

      One of my colleguage examined the issue and proposed to patch RutaEngine class to solve this issue.

      We added the following lines to:

      private void resetEnvironment(RutaModule module, CAS cas):

      641a642,646

      > final Collection<RutaModule> scripts = module.getScripts().values();

      > for (final RutaModule subModule : scripts)

      { > resetEnvironment(subModule, cas); > }

      This solves the issue in our applications which integrates Ruta.

      Known workaround: clear or initialize the variables at the end of the script.

      But I prefer if the issue is fixed in the RutaEngine class.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            pkluegl Peter Klügl
            pkluegl Peter Klügl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment