<commit_before>package alexa.skills.backbase;

import alexa.skills.backbase.lib.RestClient;
import com.amazon.speech.json.SpeechletRequestEnvelope;
import com.amazon.speech.slu.Intent;
import com.amazon.speech.slu.Slot;
import com.amazon.speech.speechlet.*;
import com.amazon.speech.speechlet.interfaces.audioplayer.AudioItem;
import com.amazon.speech.speechlet.interfaces.audioplayer.PlayBehavior;
import com.amazon.speech.speechlet.interfaces.audioplayer.Stream;
import com.amazon.speech.speechlet.interfaces.audioplayer.directive.PlayDirective;
import com.amazon.speech.ui.PlainTextOutputSpeech;
import com.amazon.speech.ui.Reprompt;
import com.amazon.speech.ui.SimpleCard;
import com.amazon.speech.ui.SsmlOutputSpeech;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

public class MyBankSpeechlet implements SpeechletV2 {

    private static final Logger log = LoggerFactory.getLogger(MyBankSpeechlet.class);
    private final RestClient restClient = new RestClient();
    private static final String MY_BANK_CART = "MyBank";
    private static final String STOP_INTENT = "AMAZON.StopIntent";
    private static final String NO_INTENT = "AMAZON.NoIntent";
    private static final String YES_INTENT = "AMAZON.YesIntent";

    private static final String STATUS_INTENT = "GetStatus";
    private static final String TRANSFER_INTENT = "Transfer";

    private static final String PERSON_NAME_SLOT = "PersonName";
    private static final String DIRECTION_SLOT = "Direction";

    private static final String WELCOME_MESSAGE = "Hi Rik, I hope everything is alright, you seem to be short on funds lately. Anything I should know about?";
    private static final String GOODBYE_MESSAGE = "Thank you and enjoy your day.";
    private static final String ACCOUNT_BALANCE_MESSAGE = "You have 1000 euros in your debit account.";
    private static final String TRANSFER_MESSAGE = "okay done, don't forget you still owe Lisa 20 euros for those drinks last Friday";
    private static final String ANOTHER_TRANSFER_MESSAGE = "done, your balance is now 450 euro's. Anything else I can do for you today?";
    private static final String UNKNOWN_MESSAGE = "Sorry, I could not understand your question.";

    @Override
    public void onSessionStarted(SpeechletRequestEnvelope<SessionStartedRequest> speechletRequestEnvelope) {
        log.info("onSessionStarted requestId={}, sessionId={}",
                speechletRequestEnvelope.getRequest().getRequestId(),
                speechletRequestEnvelope.getSession().getSessionId());
    }

    @Override
    public SpeechletResponse onLaunch(SpeechletRequestEnvelope<LaunchRequest> speechletRequestEnvelope) {
        log.info("onLaunch requestId={}, sessionId={}",
                speechletRequestEnvelope.getRequest().getRequestId(),
                speechletRequestEnvelope.getSession().getSessionId());

        return getWelcomeResponse();
    }

    @Override
    public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> speechletRequestEnvelope) {
        IntentRequest request = speechletRequestEnvelope.getRequest();

        log.info("onIntent requestId={}, sessionId={}",
                request.getRequestId(),
                speechletRequestEnvelope.getSession().getSessionId());

        Intent intent = request.getIntent();
        String intentName = (intent != null) ? intent.getName() : new String();

        switch (intentName) {
            case STOP_INTENT:
            case NO_INTENT:
            case YES_INTENT:
                return getGoodByeResponse();
            case STATUS_INTENT:
                return getStatusResponse();
            case TRANSFER_INTENT:
                return sendTransferRequest(intent);
            default:
                return getUnknownCommandResponse();
        }
    }

    @Override
    public void onSessionEnded(SpeechletRequestEnvelope<SessionEndedRequest> speechletRequestEnvelope) {
        log.info("onSessionEnded requestId={}, sessionId={}",
                speechletRequestEnvelope.getRequest().getRequestId(),
                speechletRequestEnvelope.getSession().getSessionId());
    }

    private SpeechletResponse getWelcomeResponse() {
        return createRepromptResponse(WELCOME_MESSAGE, "");
    }

    private SpeechletResponse getGoodByeResponse() {
        return createSimpleResponse(GOODBYE_MESSAGE);
    }

    private SpeechletResponse getStatusResponse() {
        return createSimpleSsmlResponse(ACCOUNT_BALANCE_MESSAGE);
    }

    private SpeechletResponse sendTransferRequest(Intent intent) {
        String direction = intent.getSlot(DIRECTION_SLOT).getValue();
        String person = intent.getSlot(PERSON_NAME_SLOT).getValue();
        log.info("Direction: " + direction + " Person: " + person);

        if ("from".equals(direction) && person.toLowerCase().contains("account")) {
            return createRepromptResponse(TRANSFER_MESSAGE, "");
        }

        return createRepromptResponse(ANOTHER_TRANSFER_MESSAGE, "");
    }

    private SpeechletResponse getUnknownCommandResponse() {
        return createSimpleResponse(UNKNOWN_MESSAGE);
    }

    private SpeechletResponse createSimpleResponse(String speechText) {
        PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
        speech.setText(speechText);

        return SpeechletResponse.newTellResponse(speech, createCard(MY_BANK_CART, speechText));
    }
<commit_msg>Updated from Euro to Dollar<commit_after>package alexa.skills.backbase;

import alexa.skills.backbase.lib.RestClient;
import com.amazon.speech.json.SpeechletRequestEnvelope;
import com.amazon.speech.slu.Intent;
import com.amazon.speech.slu.Slot;
import com.amazon.speech.speechlet.*;
import com.amazon.speech.speechlet.interfaces.audioplayer.AudioItem;
import com.amazon.speech.speechlet.interfaces.audioplayer.PlayBehavior;
import com.amazon.speech.speechlet.interfaces.audioplayer.Stream;
import com.amazon.speech.speechlet.interfaces.audioplayer.directive.PlayDirective;
import com.amazon.speech.ui.PlainTextOutputSpeech;
import com.amazon.speech.ui.Reprompt;
import com.amazon.speech.ui.SimpleCard;
import com.amazon.speech.ui.SsmlOutputSpeech;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

public class MyBankSpeechlet implements SpeechletV2 {

    private static final Logger log = LoggerFactory.getLogger(MyBankSpeechlet.class);
    private final RestClient restClient = new RestClient();

    private static final String BANK_ID = "test-bank";
    private static final String ACCOUNT_ID = "RR-000001";
    private static final String VIEW_ID = "owner";

    private static final String MY_BANK_CART = "MyBank";
    private static final String STOP_INTENT = "AMAZON.StopIntent";
    private static final String NO_INTENT = "AMAZON.NoIntent";
    private static final String YES_INTENT = "AMAZON.YesIntent";

    private static final String STATUS_INTENT = "GetStatus";
    private static final String TRANSFER_INTENT = "Transfer";

    private static final String PERSON_NAME_SLOT = "PersonName";
    private static final String DIRECTION_SLOT = "Direction";

    private static final String WELCOME_MESSAGE = "Hi %s, I hope everything is alright, you seem to be short on funds lately. Anything I should know about?";
    private static final String GOODBYE_MESSAGE = "Thank you and enjoy your day.";
    private static final String ACCOUNT_BALANCE_MESSAGE = "Well, um, unfortunately it's currently %s, in the red, Let me play some soothing music for you.";
    private static final String TRANSFER_MESSAGE = "okay done, don't forget you still owe Lisa 20 USD for those drinks last Friday";
    private static final String ANOTHER_TRANSFER_MESSAGE = "done, your balance is now 450 USD. Anything else I can do for you today?";
    private static final String UNKNOWN_MESSAGE = "Sorry, I could not understand your question.";

    @Override
    public void onSessionStarted(SpeechletRequestEnvelope<SessionStartedRequest> speechletRequestEnvelope) {
        log.info("onSessionStarted requestId={}, sessionId={}",
                speechletRequestEnvelope.getRequest().getRequestId(),
                speechletRequestEnvelope.getSession().getSessionId());
    }

    @Override
    public SpeechletResponse onLaunch(SpeechletRequestEnvelope<LaunchRequest> speechletRequestEnvelope) {
        log.info("onLaunch requestId={}, sessionId={}",
                speechletRequestEnvelope.getRequest().getRequestId(),
                speechletRequestEnvelope.getSession().getSessionId());

        return getWelcomeResponse();
    }

    @Override
    public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> speechletRequestEnvelope) {
        IntentRequest request = speechletRequestEnvelope.getRequest();

        log.info("onIntent requestId={}, sessionId={}",
                request.getRequestId(),
                speechletRequestEnvelope.getSession().getSessionId());

        Intent intent = request.getIntent();
        String intentName = (intent != null) ? intent.getName() : new String();

        switch (intentName) {
            case STOP_INTENT:
            case NO_INTENT:
            case YES_INTENT:
                return getGoodByeResponse();
            case STATUS_INTENT:
                return getStatusResponse();
            case TRANSFER_INTENT:
                return sendTransferRequest(intent);
            default:
                return getUnknownCommandResponse();
        }
    }

    @Override
    public void onSessionEnded(SpeechletRequestEnvelope<SessionEndedRequest> speechletRequestEnvelope) {
        log.info("onSessionEnded requestId={}, sessionId={}",
                speechletRequestEnvelope.getRequest().getRequestId(),
                speechletRequestEnvelope.getSession().getSessionId());
    }

    private SpeechletResponse getWelcomeResponse() {
        String name = restClient.getAccountDisplayName(BANK_ID, ACCOUNT_ID, VIEW_ID);

        return createRepromptResponse(String.format(WELCOME_MESSAGE, name), "");
    }

    private SpeechletResponse getGoodByeResponse() {
        return createSimpleResponse(GOODBYE_MESSAGE);
    }

    private SpeechletResponse getStatusResponse() {
        String balance = restClient.getAccountBalance(BANK_ID, ACCOUNT_ID, VIEW_ID);

        return createSimpleSsmlResponse(String.format(ACCOUNT_BALANCE_MESSAGE, balance));
    }

    private SpeechletResponse sendTransferRequest(Intent intent) {
        String direction = intent.getSlot(DIRECTION_SLOT).getValue();
        String person = intent.getSlot(PERSON_NAME_SLOT).getValue();
        log.info("Direction: " + direction + " Person: " + person);

        if (person.toLowerCase().contains("account")) {
            return createRepromptResponse(TRANSFER_MESSAGE, "");
        }

        return createRepromptResponse(ANOTHER_TRANSFER_MESSAGE, "");
    }

    private SpeechletResponse getUnknownCommandResponse() {
        return createSimpleResponse(UNKNOWN_MESSAGE);
    }

    private SpeechletResponse createSimpleResponse(String speechText) {
        PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
        speech.setText(speechText);

        return SpeechletResponse.newTellResponse(speech, createCard(MY_BANK_CART, speechText));
    }

{'fraction_non_alphanumeric': 0.08632138114209828, 'fraction_numerical': 0.0023019034971226205, 'mean_word_length': 3.75821398483572, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2407657', 'n_tokens_mistral': 3154, 'n_tokens_neox': 2977, 'n_words': 702}