Package it.freedomotic.core

Examples of it.freedomotic.core.NaturalLanguageProcessor


    private BusService busService;
   
  public SpeechEvent(Object source, String phrase) {
        this.setSender(source);

        NaturalLanguageProcessor nlp = new NaturalLanguageProcessor();
        List<NaturalLanguageProcessor.Rank> mostSimilar = nlp.getMostSimilarCommand(phrase, 10);

        if (!mostSimilar.isEmpty()) {
            Command c = mostSimilar.get(0).getCommand();
            System.out.println("execute speech command: " + c.getName());
View Full Code Here


    private String manageMessage(String mess) {
        Command c;
        Trigger t = null;
        Reaction r;
        NaturalLanguageProcessor nlp2 = new NaturalLanguageProcessor();
        //  String sentenceMess[] = nlp.getSentenceDetector().sentDetect(mess);
        String tokenMess[] = mess.split(" "); //nlp.getTokenizer().tokenize(sentenceMess[0]);
        String triggername = "";
        int conditionSep = 0;
        if (tokenMess[0].equalsIgnoreCase(HELP)) {
            return help(tokenMess);
        }
        if (tokenMess[0].equalsIgnoreCase(LIST)) {
            return list(tokenMess);
        }

        if (tokenMess[0].equalsIgnoreCase(IF) || tokenMess[0].equalsIgnoreCase(WHEN)) {
            for (int i = 1; i < tokenMess.length; i++) {
                if (tokenMess[i].equalsIgnoreCase(THEN)) {
                    triggername = unsplit(tokenMess, 1, i - 1, " ");
                    conditionSep = i + 1;
                    break;
                }
            }
            t = TriggerPersistence.getTrigger(triggername);
        }

        String commandName = unsplit(tokenMess, conditionSep, tokenMess.length - conditionSep, " ");
        List<NaturalLanguageProcessor.Rank> mostSimilar = nlp2.getMostSimilarCommand(commandName, 10);
        // user is asking for help
        if (commandName.contains("*")) {
            String response = "";
            for (NaturalLanguageProcessor.Rank nlpr : mostSimilar) {
                response += "? " + nlpr.getCommand().getName() + "\n";
View Full Code Here

TOP

Related Classes of it.freedomotic.core.NaturalLanguageProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.