vvcephei avatar vvcephei committed 2086cfd

implemented -f option for ignoring errors and creating output anyway.

Comments (0)

Files changed (3)

     (( EXIT_CODE += $? ))
 
 elif [[ $CMD = 'treemerge' ]]; then
-    treemerge.sh $1
+    treemerge.sh $1 $2
     (( EXIT_CODE += $? ))
 
 elif [ $CMD = 'viz' ]; then
                     lang=$( basename $( dirname $( dirname $( dirname $( dirname $fullpath ) ) ) ) )
                     echo "merging $fullpath to $root/$lang/tree/$collection/$base.tree"
                     #echo "running: scalabha run opennlp.scalabha.tree.Merge -i $fullpath -o $root/$lang/tree/$collection/$base.tree"
-                    scalabha run opennlp.scalabha.tree.Merge --pprintErrs -i $fullpath -o $root/$lang/tree/$collection/$base.tree
+                    if [[ $2 == "-f" ]]; then
+                      scalabha run opennlp.scalabha.tree.Merge -f -i $fullpath -o $root/$lang/tree/$collection/$base.tree
+                    else
+                      scalabha run opennlp.scalabha.tree.Merge --pprintErrs -i $fullpath -o $root/$lang/tree/$collection/$base.tree
+                    fi
                     (( exit_code += $? ))
                 else
                     echo 

src/main/scala/opennlp/scalabha/tree/Merge.scala

   val help = parser.flag[Boolean](List("h", "help"), "print help")
   val input = parser.option[String](List("i", "input"), "FILEorDIR", "tree source file or directory to compile")
   val output = parser.option[String](List("o", "output"), "FILE", "output file to write compiled trees to.")
-  val skipErrs = parser.flag[Boolean](List("f","skipErrs"),"Do not exit on errors. " +
+  val skipErrs = parser.flag[Boolean](List("f", "skipErrs"), "Do not exit on errors. " +
     "The default is to exit as soon as errors are caught in any input file.")
   val pprintErrs = parser.flag[Boolean](List("pprintErrs"), "Format treenodes nicely in error reporting.")
-  
+
   var log = new SimpleLogger(this.getClass().getName, SimpleLogger.WARN, new BufferedWriter(new OutputStreamWriter(System.err)))
 
-  
+
   def applyFile(file: File): List[TreeNode] = {
     if (file.getName.endsWith("tree"))
       MultiLineTreeParser(file.getName, scala.io.Source.fromFile(file, "UTF-8"))
       val (warnings, errors) = (compileWarnings + parseWarnings, compileErrors + parseErrors)
 
       log.summary("Warnings,Errors: %s\n".format((warnings, errors)))
-      if (errors == 0){
+      if (errors == 0 || skipErrs.value.isDefined) {
         val outputBuffer = output.value match {
           case Some(filename) =>
             if (filename.endsWith(".tree")) {
         outputBuffer.write(parsedTrees.map(tree => tree.getCanonicalString()).mkString("\n") + "\n")
 
         outputBuffer.close()
+      } else {
+        log.summary("Suspending output since there were errors.\n")
+        System.exit(errors)
       }
-      else
-      log.summary("Suspending output since there were errors.\n")
-
-      System.exit(errors)
-    }
-    catch {
+    } catch {
       case e: ArgotUsageException =>
         println(e.message)
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.