Examples of Forest


Examples of edu.uci.ics.jung.graph.Forest

   
    @SuppressWarnings("unchecked")
  public void collapse(Layout layout, Forest tree, Object subRoot) throws InstantiationException, IllegalAccessException {
       
      // get a sub tree from subRoot
      Forest subTree = TreeUtils.getSubTree(tree, subRoot);
      Object parent = null;
      Object edge = null;
      if(tree.getPredecessorCount(subRoot) > 0) {
        parent = tree.getPredecessors(subRoot).iterator().next();
        edge = tree.getInEdges(subRoot).iterator().next();
View Full Code Here

Examples of edu.uci.ics.jung.graph.Forest

            public void actionPerformed(ActionEvent e) {
                Collection picked =new HashSet(vv.getPickedVertexState().getPicked());
                if(picked.size() == 1) {
                  Object root = picked.iterator().next();
                    Forest inGraph = (Forest)layout.getGraph();

                    try {
            collapser.collapse(vv.getGraphLayout(), inGraph, root);
          } catch (InstantiationException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          } catch (IllegalAccessException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }

                    vv.getPickedVertexState().clear();
                    vv.repaint();
                }
            }});

        JButton expand = new JButton("Expand");
        expand.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Collection picked = vv.getPickedVertexState().getPicked();
                for(Object v : picked) {
                    if(v instanceof Forest) {
                        Forest inGraph = (Forest)layout.getGraph();
                  collapser.expand(inGraph, (Forest)v);
                    }
                    vv.getPickedVertexState().clear();
                   vv.repaint();
                }
View Full Code Here

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

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

  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

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

   * @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

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

    /**
     * 词典的构造.一行一个词后面是参数.可以从文件读取.可以是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

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

  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

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

   * @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
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.