public ParseResultList HandText(String text) { ArrayList<SentenceObject> resultList = new ArrayList<SentenceObject>(); ArrayList<WordObj> mSegList = wm.getSegList(text); int resultscore = Integer.MAX_VALUE; if (mSegList.size() == 1) { if (mSegList.get(0).getType().equals("父动作")) { return null; } } for (SentenceObject s : mHash.values()) { // 数值越小,表示越准确 int tempReuslt = wm.comPair(mSegList, s.getTextObjects()) + s.getResultDistance(); // 取得最接近的家电 if (tempReuslt < resultscore) { resultscore = tempReuslt; resultList.clear(); resultList.add(s); } else if (tempReuslt == resultscore) { // 累计得分相同项 resultList.add(s); } } LogManager.e("result score " + resultscore); ParseResultList result = new ParseResultList(resultList, resultscore); isHouseCommand(text); return result; }
public void addContent(String corder, String dorder, String target) { LogManager.e(corder); SentenceObject s = new SentenceObject(wm.getSegList(corder), corder); s.setOrder(dorder); s.setTarget(target); LogManager.e(s.toString()); mHash.put(corder, s); }