Changeset 33397


Ignore:
Timestamp:
2019-08-11T19:30:49+12:00 (5 years ago)
Author:
ak19
Message:
  1. Changing package structure and instructions on compiling/running as there will be more Java classes. 2. Minor fix so that when MaoriDetector is run with min-min-help it doesn't print out the ERROR expecting request to read from filename/stdinput.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/maori-lang-detection/src/MaoriTextDetector.java

    r33355 r33397  
    1919 */
    2020
     21package org.greenstone.atea;
     22
    2123import java.io.*;
    2224import opennlp.tools.langdetect.*;
     
    2931 *
    3032 * Then, to compile this program, do the following from the "src" folder (the folder containing this java file):
    31  *    maori-lang-detection/src$ javac -cp ".:$OPENNLP_HOME/lib/opennlp-tools-1.9.1.jar" MaoriTextDetector.java
     33 *    maori-lang-detection/src$ javac -cp ".:$OPENNLP_HOME/lib/opennlp-tools-1.9.1.jar" org/greenstone/atea/MaoriTextDetector.java
    3234 *
    3335 * To run this program, issue one of the following commands from the "src" folder (the folder containing this java file):
    3436 *
    35  *    maori-lang-detection/src$ java -cp ".:$OPENNLP_HOME/lib/*" MaoriTextDetector --help
    36  *
    37  *    maori-lang-detection/src$ java -cp ".:$OPENNLP_HOME/lib/*" MaoriTextDetector --file <full/path/to/textfile>
    38  *
    39  *    maori-lang-detection/src$ java -cp ".:$OPENNLP_HOME/lib/*" MaoriTextDetector -
     37 *    maori-lang-detection/src$ java -cp ".:$OPENNLP_HOME/lib/opennlp-tools-1.9.1.jar" org.greenstone.atea.MaoriTextDetector --help
     38 *
     39 *    maori-lang-detection/src$ java -cp ".:$OPENNLP_HOME/lib/opennlp-tools-1.9.1.jar" org.greenstone.atea.MaoriTextDetector --file <full/path/to/textfile>
     40 *
     41 *    maori-lang-detection/src$ java -cp ".:$OPENNLP_HOME/lib/opennlp-tools-1.9.1.jar" org.greenstone.atea.MaoriTextDetector -
    4042 *       Press enter. This variant of the program expects text to stream in from standard input.
    4143 *       If entering text manually, then remember to press Ctrl-D to indicate the usual end of StdIn.
     
    363365    }
    364366
    365     if(!readFromStdIn && inFile == null) { // at least one input source must be provided
    366         doPrintErr(runSilent, "ERROR: must specify source to read text from, either STDIN (-) or input file (--file <file>).\n");
    367         printUsage = true;
    368         returnVal = -1;
    369     }
    370    
    371     if(readFromStdIn && inFile != null) { // this program can't be asked to read from stdin and from an input file
    372         doPrintErr(runSilent, "ERROR: instructed to read from both STDIN and from an input file. Not possible.\n");
    373         printUsage = true;
    374         returnVal = -1;
     367    if(returnVal != 2) { // returnVal == 2 for help. Only if the user did not request --help/-h, do we continue to make sure the arguments provided are sane
     368        if(!readFromStdIn && inFile == null) { // at least one input source must be provided
     369        doPrintErr(runSilent, "ERROR: must specify source to read text from, either STDIN (-) or input file (--file <file>).\n");
     370        printUsage = true;
     371        returnVal = -1;
     372        }
     373       
     374        if(readFromStdIn && inFile != null) { // this program can't be asked to read from stdin and from an input file
     375        doPrintErr(runSilent, "ERROR: instructed to read from both STDIN and from an input file. Not possible.\n");
     376        printUsage = true;
     377        returnVal = -1;
     378        }
    375379    }
    376380   
Note: See TracChangeset for help on using the changeset viewer.