perchance chatbot code

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Random;

public class Joker {
    /*
     * extend me and add sentences and lists for parameters in the sentences in the
     * sub classes c'tor. see JokerIncel class for exammple see Joker Util class for
     * editing a large amount of data faster B4 adding it in the subclasses c'tor
     */
    protected ArrayList<String> sentences = new ArrayList<String>();
    protected Hashtable<String, ArrayList<String>> wordToList = new Hashtable<>();
    protected Random rand = new Random();
    private RegexUtil regexUtil = new RegexUtil();
    public Joker() {
        super();
    }

    public String generateJoke() {
        int x = rand.nextInt(sentences.size());
        String result = sentences.get(x);
        return clearRecursion(result);
    }

    private String clearRecursion(String result) {
        int x;
        ArrayList<String> params = new ArrayList<String>();
        params = regexUtil.regexChecker2("(\\w+)(?= #)", result);
        for (String strI : params) {
            ArrayList<String> temp = wordToList.get(strI);
            int n = temp.size();
            x = rand.nextInt(n);
            String s1 = temp.get(x);
            result = result.replace(strI + " #", s1);
        }
        if (!result.contains("#")) {
            return result;
        } else {
            return clearRecursion(result);
        }
        // return "";
    }
}

@fukurou
:h3:
 

fukurou

the supreme coder
ADMIN
12A34B56

{hardcoded, shallowref to DB obj}
{category, list}

[fixures] // que

[imagined outputs] // remove failed :s69:
 

owly

闇の伝説
Staff member
戦闘 コーダー
ain't it funny how you think I be playin

show me some code! :s79:
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.RegexUtil;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Random;

public class PerChance {/*
 * extend me and add sentences and lists for parameters in the sentences in the
 * sub classes c'tor. see JokerIncel class for exammple see Joker Util class for
 * editing a large amount of data faster B4 adding it in the subclasses c'tor
 */
    protected ArrayList<String> sentences = new ArrayList<String>();
    protected Hashtable<String, UniqueItemSizeLimitedPriorityQueue> wordToList = new Hashtable<>();
    protected Random rand = new Random();
    private RegexUtil regexUtil = new RegexUtil();
    public PerChance() {
        super();
    }

    public String generateJoke() {
        int x = rand.nextInt(sentences.size());
        String result = sentences.get(x);
        return clearRecursion(result);
    }

    private String clearRecursion(String result) {
        int x;
        ArrayList<String> params = new ArrayList<String>();
        params = regexUtil.extractAllRegexes("(\\w+)(?= #)", result);
        for (String strI : params) {
            UniqueItemSizeLimitedPriorityQueue temp = wordToList.get(strI);
            int n = temp.size();
            String s1 = temp.getRNDElement();
            result = result.replace(strI + " #", s1);
        }
        if (!result.contains("#")) {
            return result;
        } else {
            return clearRecursion(result);
        }
    }
    public void addParam(String category, String value){
        if(wordToList.containsKey(category)){
            wordToList.get(category).add(value);
        }
    }
}
chill homes, I was playin some centrion mk11
 

owly

闇の伝説
Staff member
戦闘 コーダー
hmm, so that's what neuro "sama" looks like from the inside
lets make a wrapper AXL class.
and by lets I mean you
 
Top