Ejemplo n.º 1
0
  /**
   * Initialize resources and processors that has been config, and register them in Resource Manager
   *
   * @param propertiesManager
   * @return
   */
  public boolean initialize(PropertiesManager propertiesManager) {
    assert propertiesManager != null;
    this.propertiesManager = propertiesManager;
    // this.configurables = new ArrayList<Configurable>();
    // read the config and initialize those resources and processors that has been config
    // TODO; only initialize the resources and processors by reflection from the feature sets, has
    // to change the framework to start
    try {
      String srcLang = this.getSrcLang();
      String trgLang = this.getTrgLang();

      // slang dict only for the target
      SlangDictionary trgSlangDict = new SlangDictionary(trgLang);
      if (trgSlangDict.isConfigured(propertiesManager)) {
        trgSlangDict.load(propertiesManager);
        trgSlangDict.register();
        VariantsSlangProcessor p1 = new VariantsSlangProcessor(trgSlangDict);
        this.trgResourceProcessors.add(p1);
      }

      // abbreviation
      AbbreviationDictionary abbrevDict = new AbbreviationDictionary(trgLang);
      if (abbrevDict.isConfigured(propertiesManager)) {
        abbrevDict.load(propertiesManager);
        abbrevDict.register();
        AbbreviationsProcessor p2 = new AbbreviationsProcessor(abbrevDict);
        this.trgResourceProcessors.add(p2);
      }

      // other features

    } catch (Exception e) {
      isInitialized = false;
      return false;
    }
    isInitialized = true;
    return true;
  }