예제 #1
0
  public void init() {
    try {
      // open model file
      finModel = option.openModelFile();
      if (finModel == null) {
        System.out.println("Couldn't open model file");
        return;
      }

      data = new Data(option);
      // read context predicate map
      data.readCpMaps(finModel);
      // read label map
      data.readLbMaps(finModel);

      dict = new Dictionary(option, data);
      // read dictionary
      dict.readDict(finModel);

      feagen = new FeatureGen(option, data, dict);
      // read features
      feagen.readFeatures(finModel);

      // create an inference object
      inference = new Inference();

      // create a model object
      model = new Model(option, data, dict, feagen, null, inference, null);
      model.initInference();

      // close model file
      finModel.close();

    } catch (IOException e) {
      System.out.println("Couldn't load the model, check the model file again");
      System.out.println(e.toString());
    }

    intCps = new ArrayList();

    initialized = true;
  }