Package org.nlpcn.commons.lang.tire.domain

Examples of org.nlpcn.commons.lang.tire.domain.Forest


     * 词典的构造.一行一个词后面是参数.可以从文件读取.可以是read流.
     */
    long start = System.currentTimeMillis();
    String dic = "android\t10\t孙健\nc\t100\nC++\t10\nc++\t5\nc#\t100\nVC++\t100".toLowerCase();
    System.out.println(dic);
    Forest forest = Library.makeForest(new BufferedReader(new StringReader(dic)));
    /**
     * 删除一个单词
     */
    Library.removeWord(forest, "中国");
    /**
     * 增加一个新词
     */
    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);
View Full Code Here


  public static Forest makeForest(InputStream inputStream) throws Exception {
    return makeForest(IOUtil.getReader(inputStream, "UTF-8"));
  }

  public static Forest makeForest(BufferedReader br) throws Exception {
    return makeLibrary(br, new Forest());
  }
View Full Code Here

   * @param values
   * @param forest
   * @return
   */
  public static Forest makeForest(List<Value> values) {
    Forest forest = new Forest();
    for (Value value : values) {
      insertWord(forest, value.toString());
    }
    return forest;
  }
View Full Code Here

    /**
     * 词典的构造.一行一个词后面是参数.可以从文件读取.可以是read流.
     */
    long start = System.currentTimeMillis();
    String dic = "android\t10\nc\t100\nC++\t10\nc++\t5\nc#\t100\nVC++\t100".toLowerCase();
    Forest forest = Library.makeForest(new BufferedReader(new StringReader(dic)));
    /**
     * 删除一个单词
     */
    Library.insertWord(forest, "中国");
    /**
     * 增加一个新词
     */
    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(2));
      }
View Full Code Here

  private static Forest initRev(String dicName, InputStream is) {
    BufferedReader reader = null;
    try {
      reader = IOUtil.getReader(is, IOUtil.UTF8);
      Forest forest = new Forest();
      String temp = null;
      String[] strs = null;
      while ((temp = reader.readLine()) != null) {
        strs = temp.trim().split("\t");
        if (strs.length != 2) {
View Full Code Here

   * @param filePath
   * @return
   * @throws Exception
   */
  public synchronized static Forest makeForest(String dicName, BufferedReader br) throws Exception {
    Forest forest = null;
    if ((forest = forestMap.get(dicName)) != null) {
      return forest;
    }
    forest = Library.makeForest(br);

View Full Code Here

TOP

Related Classes of org.nlpcn.commons.lang.tire.domain.Forest

Copyright © 2018 www.massapicom. 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.