Example #1
0
  static {
    IOFile dic = null;
    if (Reflect.available(PATTERN)) {
      dic = new IOFile(LANG);
      if (!dic.exists()) {
        dic = new IOFile(Prop.HOME, "etc/" + LANG);
        if (!dic.exists()) {
          available = false;
        }
      }
    } else {
      available = false;
    }

    if (available) {
      Class<?> clz = Reflect.find(PATTERN);
      if (clz == null) {
        Util.debug("Could not initialize Igo Japanese lexer.");
      } else {
        /* Igo constructor. */
        final Constructor<?> tgr = Reflect.find(clz, String.class);
        tagger = Reflect.get(tgr, dic.path());
        if (tagger == null) {
          available = false;
          Util.debug("Could not initialize Igo Japanese lexer.");
        } else {
          parse = Reflect.method(clz, "parse", CharSequence.class);
          if (parse == null) {
            Util.debug("Could not initialize Igo lexer method.");
          }
          clz = Reflect.find("net.reduls.igo.Morpheme");
          surface = Reflect.field(clz, "surface");
          feature = Reflect.field(clz, "feature");
          start = Reflect.field(clz, "start");
        }
      }
    }
  }