Пример #1
0
 public void forall(Category c) {
   // get feature structures
   if (!(c instanceof AtomCat)) return;
   String type = ((AtomCat) c).getType();
   FeatureStructure fs = c.getFeatureStructure();
   GFeatStruc gfs = (GFeatStruc) fs;
   if (gfs == null || gfs.getInheritsFrom() == 0) return;
   int inhf = gfs.getInheritsFrom();
   FeatureStructure inhfFS = (FeatureStructure) featStrucMap.get(inhf);
   if (inhfFS != null) {
     // copy values of features from inhfFS not already present
     for (Iterator<String> it = inhfFS.getAttributes().iterator(); it.hasNext(); ) {
       String att = it.next();
       if (gfs.hasAttribute(att)) continue;
       gfs.setFeature(att, UnifyControl.copy(inhfFS.getValue(att)));
     }
     // for each possible attr used with this type and not already present,
     // add feature equation
     Collection<String> attrs = (Collection<String>) _catsToAttrs.get(type);
     if (attrs == null) return;
     for (Iterator<String> it = attrs.iterator(); it.hasNext(); ) {
       String att = it.next();
       if (gfs.hasAttribute(att)) continue;
       String varName = att.toUpperCase() + inhf;
       if (_lfAttrs.contains(att)) {
         gfs.setFeature(att, new HyloVar(varName));
         inhfFS.setFeature(att, new HyloVar(varName));
       } else {
         gfs.setFeature(att, new GFeatVar(varName));
         inhfFS.setFeature(att, new GFeatVar(varName));
       }
     }
   } else {
     System.err.println(
         "Warning: no feature structure with inheritsFrom index of "
             + inhf
             + " found in category "
             + c);
   }
 }
Пример #2
0
 public void forall(Category c) {
   if (!(c instanceof AtomCat)) return;
   FeatureStructure fs = c.getFeatureStructure();
   if (fs == null) return;
   for (int i = 0; i < _distributiveAttrs.length; i++) {
     if (distrAttrVals[i].size() != 1) continue;
     Object distVal = distrAttrVals[i].get(0);
     String attr = _distributiveAttrs[i];
     Object val = fs.getValue(attr);
     if (val == null) {
       fs.setFeature(attr, UnifyControl.copy(distVal));
     }
   }
 }
Пример #3
0
 public void modify(Mutable m) {
   if (m instanceof Proposition) {
     Proposition prop = (Proposition) m;
     if (prop.getName().equals(DEFAULT_VAL)) prop.setAtomName(REPLACEMENT);
   } else if (m instanceof FeatureStructure) {
     FeatureStructure fs = (FeatureStructure) m;
     for (Iterator<String> it = fs.getAttributes().iterator(); it.hasNext(); ) {
       String attr = it.next();
       Object val = fs.getValue(attr);
       if (val instanceof SimpleType && ((SimpleType) val).getName().equals(DEFAULT_VAL)) {
         fs.setFeature(attr, grammar.types.getSimpleType(REPLACEMENT));
       }
     }
   }
 }