GuessMorph.java 1.57 KB
Newer Older
priyank's avatar
priyank committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
package in.cdacn.nlp.ilmt;

import gnu.getopt.Getopt;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

public class GuessMorph
{
  static String stHomedirPath = null;
  static boolean isOutputFile = false;
  static boolean isDaemon = false;
  static int daemonPort = 0;

  public static void main(String[] args)
  {
    Getopt getoptChoice = new Getopt("GuessMorph", args, "i:o:u:p:d");

    String input = null;
    boolean flag_fileoutput = false;
    String op_file = null;
    int option;
    while ((option = getoptChoice.getopt()) != -1)
    {
      switch (option)
      {
      case 100:
        isDaemon = true;
        break;
      case 112:
        daemonPort = Integer.parseInt(getoptChoice.getOptarg());
        break;
      case 105:
        input = getoptChoice.getOptarg();

        break;
      case 111:
        isOutputFile = true;

        op_file = getoptChoice.getOptarg();

        break;
      case 117:
        stHomedirPath = getoptChoice.getOptarg();
      }

    }

    try
    {
        if (input != null)
            new SSFReading().convertFile(input, op_file);
        else {
            if (daemonPort != 0) {
                new SSFReading().convertFile(null, op_file);
            } else {
                System.out.println("Please pass the port number to -p :)\n");
            }
        }
    } catch (FileNotFoundException ex) {
        ex.printStackTrace();
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
  }
}