@Override
    public String stem(String word) {
        b = word.toCharArray();

        k = word.length() - 1;
        if (k > 1) {
            step1();
            step2();
            step3();
            step4();
            step5();
            step6();
        }

        return new String(b, 0, k+1);
    }
@Test
    public void testStem() {
        System.out.println("stem");
        String[] words = {"consign", "consigned", "consigning", "consignment",
            "consist", "consisted", "consistency", "consistent", "consistently",
            "consisting", "consists", "consolation", "consolations", "consolatory",
            "console", "consoled", "consoles", "consolidate", "consolidated",
            "consolidating", "consoling", "consolingly", "consols", "consonant",
            "consort", "consorted", "consorting", "conspicuous", "conspicuously",
            "conspiracy", "conspirator", "conspirators", "conspire", "conspired",
            "conspiring", "constable", "constables", "constance", "constancy",
            "constant", "knack", "knackeries", "knacks", "knag", "knave",
            "knaves", "knavish", "kneaded", "kneading", "knee", "kneel",
            "kneeled", "kneeling", "kneels", "knees", "knell", "knelt", "knew",
            "knick", "knif", "knife", "knight", "knightly", "knights", "knit",
            "knits", "knitted", "knitting", "knives", "knob", "knobs", "knock",
            "knocked", "knocker", "knockers", "knocking", "knocks", "knopp",
            "knot", "knots"
        };

        String[] expResult = {"consign", "consign", "consign", "consign",
            "consist", "consist", "consist", "consist", "consist", "consist",
            "consist", "consol", "consol", "consolatori", "consol", "consol",
            "consol", "consolid", "consolid", "consolid", "consol", "consolingli",
            "consol", "conson", "consort", "consort", "consort", "conspicu",
            "conspicu", "conspiraci", "conspir", "conspir", "conspir", "conspir",
            "conspir", "constabl", "constabl", "constanc", "constanc", "constant",
            "knack", "knackeri", "knack", "knag", "knave", "knave", "knavish",
            "knead", "knead", "knee", "kneel", "kneel", "kneel", "kneel", "knee",
            "knell", "knelt", "knew", "knick", "knif", "knife", "knight",
            "knightli", "knight", "knit", "knit", "knit", "knit", "knive", "knob",
            "knob", "knock", "knock", "knocker", "knocker", "knock", "knock",
            "knopp", "knot", "knot"
        };

        PorterStemmer instance = new PorterStemmer();
        for (int i = 0; i < words.length; i++) {
            String result = instance.stem(words[i]);
            assertEquals(expResult[i], result);
        }
    }