Esempio n. 1
0
 public void forall(Category c) {
   if (!(c instanceof AtomCat)) return;
   String type = ((AtomCat) c).getType();
   FeatureStructure fs = c.getFeatureStructure();
   if (fs == null) return;
   for (Iterator<String> it = fs.getAttributes().iterator(); it.hasNext(); ) {
     String att = it.next();
     _catsToAttrs.put(type, att);
     if (fs.getValue(att) instanceof LF) {
       _lfAttrs.add(att);
     }
   }
 }
Esempio n. 2
0
 @SuppressWarnings("unchecked")
 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++) {
     String attr = _distributiveAttrs[i];
     Object val = fs.getValue(attr);
     if (val != null && !distrAttrVals[i].contains(val)) {
       distrAttrVals[i].add(val);
     }
   }
 }
Esempio n. 3
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));
     }
   }
 }
Esempio n. 4
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));
       }
     }
   }
 }
Esempio n. 5
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);
   }
 }