Exemplo 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);
     }
   }
 }
Exemplo 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);
     }
   }
 }
Exemplo 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));
     }
   }
 }
Exemplo n.º 4
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);
   }
 }
Exemplo n.º 5
0
 public void forall(Category c) {
   FeatureStructure fs = c.getFeatureStructure();
   if (fs != null && fs.getIndex() != 0) featStrucMap.put(fs.getIndex(), fs);
 }