Java Code Examples for org.nlpcn.commons.lang.tire.domain.SmartForest#get()
The following examples show how to use
org.nlpcn.commons.lang.tire.domain.SmartForest#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NatureRecognition.java From deeplearning4j with Apache License 2.0 | 6 votes |
/** * 获取一个词语的参数 * * @param word * @return */ public String[] getParams(String word) { for (Forest forest : forests) { if (forest == null) { continue; } SmartForest<String[]> sf = forest; for (int i = 0; i < word.length(); i++) { sf = sf.get(word.charAt(i)); if (sf == null) { return null; } } if (sf.getStatus() > 1) { return sf.getParam(); } else { return null; } } return null; }
Example 2
Source File: UserDefineRecognition.java From deeplearning4j with Apache License 2.0 | 5 votes |
/** * 传入一个term 返回这个term的状态 * * @param branch * @param term * @return */ private SmartForest<String[]> termStatus(SmartForest<String[]> branch, Term term) { String name = term.getName(); SmartForest<String[]> sf = branch; for (int j = 0; j < name.length(); j++) { sf = sf.get(name.charAt(j)); if (sf == null) { return null; } } return sf; }
Example 3
Source File: NatureRecognition.java From deeplearning4j with Apache License 2.0 | 5 votes |
/** * 通过规则 猜测词性 * * @param word * @return */ public static TermNatures guessNature(String word) { String nature = null; SmartForest<String[]> smartForest = SUFFIX_FOREST; int len = 0; for (int i = word.length() - 1; i >= 0; i--) { smartForest = smartForest.get(word.charAt(i)); if (smartForest == null) { break; } len++; if (smartForest.getStatus() == 2) { nature = smartForest.getParam()[0]; } else if (smartForest.getStatus() == 3) { nature = smartForest.getParam()[0]; break; } } if ("nt".equals(nature) && (len > 1 || word.length() > 3)) { return TermNatures.NT; } else if ("ns".equals(nature)) { return TermNatures.NS; } else if (word.length() < 5) { Result parse = ToAnalysis.parse(word); for (Term term : parse.getTerms()) { if ("nr".equals(term.getNatureStr())) { return TermNatures.NR; } } } else if (ForeignPersonRecognition.isFName(word)) { return TermNatures.NRF; } return TermNatures.NW; }
Example 4
Source File: UserDicNatureRecognition.java From deeplearning4j with Apache License 2.0 | 5 votes |
public static String[] getParams(Forest forest, String word) { SmartForest<String[]> temp = forest; for (int i = 0; i < word.length(); i++) { temp = temp.get(word.charAt(i)); if (temp == null) { return null; } } if (temp.getStatus() > 1) { return temp.getParam(); } else { return null; } }