Examples of GetWord


Examples of org.nlpcn.commons.lang.tire.GetWord

    Library.insertWord(forest, "中国人");
    String content = "Android--中国人";
    content = StringUtil.rmHtmlTag(content);

    for (int i = 0; i < 1; i++) {
      GetWord udg = forest.getWord(content.toLowerCase().toCharArray());

      String temp = null;
      while ((temp = udg.getFrontWords()) != null) {
        System.out.println(temp + "\t\t" + udg.getParam(0) + "\t\t" + udg.getParam(1));
        System.out.println(udg.offe);
      }
    }
    System.out.println(System.currentTimeMillis() - start);
  }
View Full Code Here

Examples of org.nlpcn.commons.lang.tire.GetWord

  private static String toCover(Forest forest ,String str) {
    if (StringUtil.isBlank(str)) {
      return str;
    }

    GetWord word = forest.getWord(str);

    StringBuilder sb = new StringBuilder(str.length());

    String temp = null;
    int beginOffe = 0;
    while ((temp = word.getFrontWords()) != null) {
      sb.append(str.substring(beginOffe, word.offe));
      sb.append(word.getParam(0));
      beginOffe = word.offe + temp.length();
    }

    if (beginOffe < str.length()) {
      sb.append(str.substring(beginOffe, str.length()));
View Full Code Here

Examples of org.nlpcn.commons.lang.tire.GetWord

   *
   * @param content
   * @return
   */
  public GetWord getWord(String content) {
    return new GetWord(this, content);
  }
View Full Code Here

Examples of org.nlpcn.commons.lang.tire.GetWord

   *
   * @param content
   * @return
   */
  public GetWord getWord(char[] chars) {
    return new GetWord(this, chars);
  }
View Full Code Here

Examples of org.nlpcn.commons.lang.tire.GetWord

     */
    public String fingerprint(String content) {

        content = StringUtil.rmHtmlTag(content);

        GetWord word = new GetWord(forest, content);

        String temp = null;

        int middleLength = content.length() / 2;

        double factory;

        HashMap<String, MyFingerprint> hm = new HashMap<String, MyFingerprint>();

        MyFingerprint myFingerprint = null;
        while ((temp = word.getFrontWords()) != null) {
            if (temp != null && temp.length() == 0) {
                continue;
            }
            temp = temp.toLowerCase();
            factory = 1 - (Math.abs(middleLength - word.offe) / (double) middleLength);
            if ((myFingerprint = hm.get(temp)) != null) {
                myFingerprint.updateScore(factory);
            } else {
                hm.put(temp, new MyFingerprint(temp, Double.parseDouble(word.getParam(1)), factory));
            }
        }

        Set<MyFingerprint> set = new TreeSet<MyFingerprint>();
        set.addAll(hm.values());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.