Beispiel #1
0
  public String displayNONUTF() {
    List<BasicEmotion> sortedemotions = new ArrayList<BasicEmotion>(_components.size());
    String resultstring = "";

    // build ArrayList sorted by percentages

    for (BasicEmotion basicemotion : _components.keySet()) {
      if (sortedemotions.size() == 0 && _components.get(basicemotion) != 0) { // was >0
        sortedemotions.add(basicemotion);
      } else {
        boolean done = false;
        int index = sortedemotions.size();
        for (int i = 0; i < sortedemotions.size(); i++) {
          BasicEmotion sortedbasicemotion = sortedemotions.get(i);
          double current_perc = _components.get(basicemotion);
          double running_perc = _components.get(sortedbasicemotion);
          if (current_perc <= running_perc && done == false) {
            index = i;
            done = true;
          }
        }

        if (_components.get(basicemotion) != 0) // >0
        {
          sortedemotions.add(index, basicemotion);
        }
      }
    }

    for (BasicEmotion basicemotion : sortedemotions) {
      String symbol = "";
      if (basicemotion.getTheory() == EmotionTheory.PLUTCHIK) {
        PlutchikBasicEmotion pbe = (PlutchikBasicEmotion) basicemotion;
        switch (pbe) {
          case JOY:
            symbol = "joy";
            break;
          case FEAR:
            symbol = "fear";
            break;
          case SADNESS:
            symbol = "sad";
            break;
          case SURPRISE:
            symbol = "!";
            break;
          case ANTICIPATION:
            symbol = "anticip";
            break;
          case TRUST:
            symbol = "trust";
            break;
          case ANGER:
            symbol = "anger";
            break;
          case DISGUST:
            symbol = "disgust";
            break;
        }
      }
      if (basicemotion.getTheory() == EmotionTheory.EKMAN) {
        EkmanBasicEmotion pbe = (EkmanBasicEmotion) basicemotion;
        switch (pbe) {
          case AMUSEMENT:
            symbol = "amus.";
            break;
          case ANGER:
            symbol = "ang.";
            break;
          case CONTEMPT:
            symbol = "contempt";
            break;
          case CONTENTMENT:
            symbol = "contentm.";
            break;
          case DISGUST:
            symbol = "disg.";
            break;
          case EMBARASSMENT:
            symbol = "emb.";
            break;
          case EXCITEMENT:
            symbol = "exc.";
            break;
          case FEAR:
            symbol = "fear";
            break;
          case GUILT:
            symbol = "guilt";
            break;
          case PRIDEINACHIEVEMENT:
            symbol = "pr.ach.";
            break;
          case RELIEF:
            symbol = "rel.";
            break;
          case SADNESSDISTRESS:
            symbol = "sadn.dis.";
            break;
          case SATISFACTION:
            symbol = "sat.";
            break;
          case SENSORYPLEASURE:
            symbol = "sens.pleas.";
            break;
          case SHAME:
            symbol = "shame";
            break;
        }
      }
      // resultstring = symbol + String.valueOf(_components.get(basicemotion)) + " " + resultstring;
      java.text.DecimalFormat df = new java.text.DecimalFormat(".000");
      if (_components.get(basicemotion) == 0) {
      } else {
        resultstring =
            symbol
                + " "
                + String.valueOf(df.format(_components.get(basicemotion)))
                + " "
                + resultstring;
      }
    }

    return resultstring;
  }
Beispiel #2
0
 /** construct an emotion based on one singe basic emotion */
 public Emotion(BasicEmotion basicemotion, double strength) {
   assert (basicemotion != null);
   _theory = basicemotion.getTheory();
   _components.put(basicemotion, strength);
   // _strength = strength;
 }