public List<Word> sentenceProcess(String sentence) {
        List<Word> tokens = new ArrayList<Word>();
        int N = sentence.length();
        Map<Integer, List<Integer>> dag = createDAG(sentence);
        Map<Integer, Pair<Integer>> route = calc(sentence, dag);
        
        int x = 0;
        int y = 0;
        String buf = "";
        while (x < N) {
            y = route.get(x).key + 1;
            String lWord = sentence.substring(x, y);
            if (y - x == 1)
                buf += lWord;
            else {
                if (buf.length() > 0) {
                    if (buf.length() == 1) {
                        tokens.add(Word.createWord(buf));
                        buf = "";
                    } else {
                        if (wordDict.containsWord(buf)) {
                            tokens.add(wordDict.getWord(buf));
                        } else {
                            finalSeg.cut(buf, tokens);
                        }
                        buf = "";
                    }
                }
                tokens.add(Word.createWord(lWord));
            }
            x = y;
        }
        if (buf.length() > 0) {
            if (buf.length() == 1) {
                tokens.add(Word.createWord(buf));
                buf = "";
            } else {
                if (wordDict.containsWord(buf)) {
                    tokens.add(wordDict.getWord(buf));
                } else {
                    finalSeg.cut(buf, tokens);
                }
                buf = "";
            }

        }
        return tokens;
    }