Exemple #1
0
  /*
   * Count the number of occurrences of attributes combination from the item sets in the ActionDetail
   * list
   */
  private void countOccurences(
      ArrayList<AttributeItemSet> tempItemSet, ArrayList<ActionDetail> details) {
    for (int i = 0; i < details.size(); i++) {
      ActionDetail ad = details.get(i);

      for (int j = 0; j < tempItemSet.size(); j++) {
        AttributeItemSet tempAttrItemSet = tempItemSet.get(j);
        boolean match = true;
        for (int k = 0; k < tempAttrItemSet.getCandidateItemSet().size() && match == true; k++) {
          AttributeItem attrItem = tempAttrItemSet.getCandidateItemSet().get(k);
          if (attrItem.getAttrName() == "subject")
            match = attrItem.getAttrValue().equals(ad.getSubject());
          else if (attrItem.getAttrName() == "action")
            match = attrItem.getAttrValue().equals(ad.getAction());
          else if (attrItem.getAttrName() == "target")
            match = attrItem.getAttrValue().equals(ad.getTarget());
          else if (attrItem.getAttrName() == "desirability")
            match =
                attrItem.getAttrValue().equals(ad.getDesirability() >= 0 ? "positive" : "negative");
          else if (attrItem.getAttrName() == "praiseworthiness")
            match =
                attrItem
                    .getAttrValue()
                    .equals(ad.getPraiseworthiness() >= 0 ? "positive" : "negative");
          else if (attrItem.getAttrName() == "time")
            match = attrItem.getAttrValue().equals(ad.getTime().getStrRealTime());
        }
        // if all attributes and values in the item set match the values in the action detail,
        // increase
        // the coverage for the item set
        if (match) {
          tempAttrItemSet.increaseCoverage();
        }
      }
    }
  }