
org.cogchar.api.convoid.cue.VerbalCue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.cogchar.lib.convoid Show documentation
Show all versions of org.cogchar.lib.convoid Show documentation
Cogchar "convoid" - (old) conversation content + state machines
/*
* Copyright 2011 by The Cogchar Project (www.cogchar.org).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.cogchar.api.convoid.cue;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author Stu B.
*
*/
public class VerbalCue extends ConvoidCue {
private static Logger theLogger = Logger.getLogger(VerbalCue.class.getName());
static {
theLogger.setLevel(Level.ALL);
}
private Map myMeaningScoreMap;
public VerbalCue() {
myMeaningScoreMap = new HashMap();
}
public List getMeaningList() {
return new ArrayList(myMeaningScoreMap.keySet());
}
public Map getMeanings(){
return myMeaningScoreMap;
}
public void setMeanings(Map meanings){
myMeaningScoreMap = meanings;
// markContentSummaryUpdate();
}
@Override
public String toString() {
return "VerbalCue[" + getContentSummaryString() + "," + getStatString() + "]";
}
@Override
public String getContentSummaryString() {
String meaningSummary = "";
for(Entry meaning : myMeaningScoreMap.entrySet()){
meaningSummary += meaning.getKey() + " (" + meaning.getValue() + "), ";
}
meaningSummary.trim();
return meaningSummary;
}
public boolean matchesMeaningBlock(String meaningBlock) {
List meaningList = getMeaningList();
theLogger.finest("Testing meaningBlock: " + meaningBlock + " against " + meaningList);
String meanings[] = meaningBlock.split("[\\s]+");
boolean result = true;
for (int i=0; i < meanings.length; i++) {
if (!meaningList.contains(meanings[i])) {
result = false;
break;
} else {
theLogger.finest("***********meaning #" + i + "-{" + meanings[i] + "}-matches!");
}
}
theLogger.finest("returning " + result);
return result;
}
public void removeMeanings(List meanings){
boolean changed = false;
for(String m : meanings){
if(myMeaningScoreMap.containsKey(m)){
myMeaningScoreMap.remove(m);
changed = true;
}
}
if(changed){
// markContentSummaryUpdate();
markUpdated();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy