use of org.openhab.ui.habot.nlp.internal.AnswerFormatter in project habot by ghys.
the class AbstractItemIntentInterpreter method getTrainingData.
@Override
public InputStream getTrainingData(String language) throws UnsupportedLanguageException {
answerFormatter = new AnswerFormatter(language);
InputStream trainingData = Skill.class.getClassLoader().getResourceAsStream("train/" + language + "/" + this.getIntentId() + ".txt");
if (trainingData == null) {
throw new UnsupportedLanguageException(language);
}
return trainingData;
}
use of org.openhab.ui.habot.nlp.internal.AnswerFormatter in project habot by ghys.
the class HABotResource method greet.
@GET
@RolesAllowed({ Role.USER, Role.ADMIN })
@Path("/greet")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Retrieves a first greeting message from the bot in the specified or configured language.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ChatReply.class), @ApiResponse(code = 500, message = "There is no support for the configured language") })
public Response greet(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language (will use the default if omitted)") String language) {
final Locale locale = (this.localeProvider != null && this.localeProvider.getLocale() != null) ? this.localeProvider.getLocale() : LocaleUtil.getLocale(language);
AnswerFormatter answerFormatter = new AnswerFormatter(locale);
String greeting = answerFormatter.getRandomAnswer("greeting");
ChatReply reply = new ChatReply(locale);
reply.setAnswer(greeting);
return Response.ok(reply).build();
}
Aggregations