예제 #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();
        }
      }
    }
  }
예제 #2
0
  /*
   * Obtain all attribute items from the action details list
   */
  private void identityItems(ArrayList<ActionDetail> details) {
    for (int i = 0; i < details.size(); i++) {
      ActionDetail ad = details.get(i);

      if (ad.getSubject() != null) {
        // subject field
        AttributeItem subject = new AttributeItem("subject", ad.getSubject());
        this.candidateFrequentItems(subject);
      }
      if (ad.getAction() != null) {
        // action field
        AttributeItem action = new AttributeItem("action", ad.getAction());
        this.candidateFrequentItems(action);
      }
      if (ad.getTarget() != null) {
        // target field
        AttributeItem target = new AttributeItem("target", ad.getTarget());
        this.candidateFrequentItems(target);
      }

      // desirability
      AttributeItem desirability =
          new AttributeItem("desirability", ad.getDesirability() >= 0 ? "positive" : "negative");
      this.candidateFrequentItems(desirability);

      // praiseworthiness
      AttributeItem praiseworthiness =
          new AttributeItem(
              "praiseworthiness", ad.getPraiseworthiness() >= 0 ? "positive" : "negative");
      this.candidateFrequentItems(praiseworthiness);

      if (ad.getTime() != null) {
        // subject field
        AttributeItem time = new AttributeItem("time", ad.getTime().getStrRealTime());
        this.candidateFrequentItems(time);
      }
    }
  }