@@ -0,0 +1,3034 @@
+package seedu.todo.controllers.concerns;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport seedu.todo.commons.util.StringUtil;%0A%0A// @@author A0139812A%0Apublic class Disambiguator %7B%0A    %0A    private static final String TOKEN_NAME = %22name%22;%0A    private static final String PLACEHOLDER_NAME = %22%3Cname%3E%22;%0A    private static final String TOKEN_TASKSTATUS = %22taskStatus%22;%0A    private static final String PLACEHOLDER_TASKSTATUS = %22%3Ctask status%3E%22;%0A    private static final String TOKEN_EVENTSTATUS = %22eventStatus%22;%0A    private static final String PLACEHOLDER_EVENTSTATUS = %22%3Cevent status%3E%22;%0A    private static final String TOKEN_TAG = %22tag%22;%0A    private static final String PLACEHOLDER_TAG = %22%3Ctag%3E%22;%0A    private static final String TOKEN_STARTTIME = %22startTime%22;%0A    private static final String PLACEHOLDER_STARTTIME = %22%3Cstart%3E%22;%0A    private static final int INDEX_STARTTIME = 0;%0A    private static final String TOKEN_ENDTIME = %22endTime%22;%0A    private static final String PLACEHOLDER_ENDTIME = %22%3Cend%3E%22;%0A    private static final int INDEX_ENDTIME = 1;%0A    %0A    /**%0A     * Extracts the first token from each type of token. %0A     * If the token doesn't exist, it will be replaced with a default placeholder.%0A     * This is for the purpose of rendering disambiguation strings.%0A     */%0A    public static Map%3CString, String%3E extractParsedTokens(Map%3CString, String%5B%5D%3E parsedResult) %7B%0A        Map%3CString, String%3E tokens = new HashMap%3C%3E();%0A        %0A        // Extract tokens%0A        tokens.put(TOKEN_NAME, extractKeyOrValue(parsedResult, true, TOKEN_NAME, PLACEHOLDER_NAME));%0A        tokens.put(TOKEN_TASKSTATUS, extractKeyOrValue(parsedResult, false, TOKEN_TASKSTATUS, PLACEHOLDER_TASKSTATUS));%0A        tokens.put(TOKEN_EVENTSTATUS, extractKeyOrValue(parsedResult, false, TOKEN_EVENTSTATUS, PLACEHOLDER_EVENTSTATUS));%0A        tokens.put(TOKEN_TAG, extractKeyOrValue(parsedResult, true, TOKEN_TAG, PLACEHOLDER_TAG));%0A        %0A        // Time start/end%0A        String%5B%5D datePair = DateParser.extractDatePair(parsedResult);%0A        tokens.put(TOKEN_STARTTIME, StringUtil.replaceEmpty(datePair%5BINDEX_STARTTIME%5D, PLACEHOLDER_STARTTIME));%0A        tokens.put(TOKEN_ENDTIME, StringUtil.replaceEmpty(datePair%5BINDEX_ENDTIME%5D, PLACEHOLDER_ENDTIME));%0A        %0A        return tokens;%0A    %7D%0A    %0A    /**%0A     * Extracts the key or value of the token value array, and returns it.%0A     * Accepts a placeholder string in the event that the key or value doesn't exist.%0A     */%0A    private static String extractKeyOrValue(Map%3CString, String%5B%5D%3E parsedResult, boolean extractValue, String key, String placeholder) %7B%0A        int n = extractValue ? 1 : 0;%0A        %0A        // Extracts the key or value depending on extractKey.%0A        String extracted = null;%0A        if (parsedResult.get(key) != null && parsedResult.get(key).length %3E n) %7B%0A            extracted = parsedResult.get(key)%5Bn%5D;%0A        %7D%0A        %0A        // Replaces with placeholder if empty.%0A        extracted = StringUtil.replaceEmpty(extracted, placeholder);%0A        %0A        return extracted;%0A    %7D%0A%7D%0A

Add disambiguator