コード例 #1
0
ファイル: Lexicon.java プロジェクト: kevinkissi/openccg
  // returns a macro adder for the given morph item
  private MacroAdder getMacAdder(MorphItem mi) {

    // check map
    MacroAdder retval = macAdderMap.get(mi);
    if (retval != null) return retval;

    // set up macro adder
    IntHashSetMap macrosFromLex = new IntHashSetMap();
    String[] newMacroNames = mi.getMacros();
    List<MacroItem> macroItems = new ArrayList<MacroItem>();
    for (int i = 0; i < newMacroNames.length; i++) {
      Set<FeatureStructure> featStrucs = (Set<FeatureStructure>) _macros.get(newMacroNames[i]);
      if (featStrucs != null) {
        for (Iterator<FeatureStructure> fsIt = featStrucs.iterator(); fsIt.hasNext(); ) {
          FeatureStructure fs = fsIt.next();
          macrosFromLex.put(fs.getIndex(), fs);
        }
      }
      MacroItem macroItem = _macroItems.get(newMacroNames[i]);
      if (macroItem != null) {
        macroItems.add(macroItem);
      } else {
        // should be checked earlier too
        System.err.println(
            "Warning: macro " + newMacroNames[i] + " not found for word '" + mi.getWord() + "'");
      }
    }
    retval = new MacroAdder(macrosFromLex, macroItems);

    // update map and return
    macAdderMap.put(mi, retval);
    return retval;
  }
コード例 #2
0
ファイル: Lexicon.java プロジェクト: kevinkissi/openccg
 public void modify(Mutable m) {
   if (m instanceof NominalVar) {
     NominalVar nv = (NominalVar) m;
     SimpleType st = nv.getType();
     SimpleType st0 = nomvarMap.get(nv);
     // add type to map if no type found
     if (st0 == null) {
       nomvarMap.put(nv, st);
       return;
     }
     // check equality
     if (st.equals(st0)) return;
     // otherwise unify types, update nv and map
     try {
       SimpleType stU = (SimpleType) st.unify(st0, null);
       nv.setType(stU);
       nomvarMap.put(nv, stU);
     } catch (UnifyFailure uf) {
       throw new TypePropagationException(st, st0);
     }
   }
 }