Search in sources :

Example 11 with IntentInterpretation

use of org.openhab.ui.habot.nlp.IntentInterpretation in project habot by ghys.

the class GetStatusSkill method interpret.

@Override
public IntentInterpretation interpret(Intent intent, String language) {
    IntentInterpretation interpretation = new IntentInterpretation();
    Set<Item> matchedItems = findItems(intent);
    if (matchedItems == null || matchedItems.isEmpty()) {
        interpretation.setAnswer(answerFormatter.getRandomAnswer("answer_nothing_found"));
        interpretation.setHint(answerFormatter.getStandardTagHint(intent.getEntities()));
    } else {
        interpretation.setMatchedItems(matchedItems);
        interpretation.setCard(cardBuilder.buildCard(intent, matchedItems));
        interpretation.setAnswer(answerFormatter.getRandomAnswer("info_found_simple"));
    }
    return interpretation;
}
Also used : Item(org.eclipse.smarthome.core.items.Item) IntentInterpretation(org.openhab.ui.habot.nlp.IntentInterpretation)

Example 12 with IntentInterpretation

use of org.openhab.ui.habot.nlp.IntentInterpretation in project habot by ghys.

the class HistoryHourlyGraphSkill method interpret.

@Override
public IntentInterpretation interpret(Intent intent, String language) {
    IntentInterpretation interpretation = new IntentInterpretation();
    Set<Item> matchedItems = findItems(intent);
    if (matchedItems == null || matchedItems.isEmpty()) {
        interpretation.setAnswer(answerFormatter.getRandomAnswer("answer_nothing_found"));
        interpretation.setHint(answerFormatter.getStandardTagHint(intent.getEntities()));
    } else {
        interpretation.setMatchedItems(matchedItems);
        String period = "h";
        if (intent.getEntities().containsKey("period")) {
            period = intent.getEntities().get("period").concat(period);
        }
        interpretation.setCard(this.cardBuilder.buildChartCard(intent, matchedItems, period));
    }
    interpretation.setAnswer(answerFormatter.getRandomAnswer("info_found_simple"));
    return interpretation;
}
Also used : Item(org.eclipse.smarthome.core.items.Item) IntentInterpretation(org.openhab.ui.habot.nlp.IntentInterpretation)

Aggregations

IntentInterpretation (org.openhab.ui.habot.nlp.IntentInterpretation)12 Item (org.eclipse.smarthome.core.items.Item)11 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)5 Intent (org.openhab.ui.habot.nlp.Intent)5 Skill (org.openhab.ui.habot.nlp.Skill)5 Reference (org.osgi.service.component.annotations.Reference)5 EventPublisher (org.eclipse.smarthome.core.events.EventPublisher)4 AbstractItemIntentInterpreter (org.openhab.ui.habot.nlp.AbstractItemIntentInterpreter)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 List (java.util.List)3 ItemEventFactory (org.eclipse.smarthome.core.items.events.ItemEventFactory)3 CardBuilder (org.openhab.ui.habot.card.CardBuilder)3 Locale (java.util.Locale)2 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)2 Card (org.openhab.ui.habot.card.Card)2 InputStream (java.io.InputStream)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1