Examples of SegResult


Examples of org.ictclas4j.bean.SegResult

      ArrayList<String> testCases = GFFile.readTxtFile2("test" + GFFinal.FILE_SEP + "case1.txt");

      long times = System.currentTimeMillis();
      for (int i = 0; i < forCount; i++) {
        for (String src : testCases) {
          SegResult sr = seg.split(src);
          bytes += src.getBytes().length;
          //��ӡ����Ἣ���Ӱ���ٶ�
//          System.out.println(sr);
        }
      }
View Full Code Here

Examples of org.ictclas4j.bean.SegResult

      jbSplitOK.setText("�ִ�");
      jbSplitOK.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
          int segPathCount = Integer.parseInt(jtSegPathCount.getText());
          SegMain.seg.setSegPathCount(segPathCount);
          SegResult sr = SegMain.seg.split(jtSrcMsg.getText());
          jtSplitMsg.setText("[Time:" + sr.getSpendTime() + "ms]:\n" + sr.getFinalResult());
        }
      });
    }
    return jbSplitOK;
  }
View Full Code Here

Examples of org.ictclas4j.bean.SegResult

            SegMain.seg.setSegPathCount(segPathCount);
            int forCount=Integer.parseInt(jtFor.getText());
            ArrayList<String> testCases = GFString.readTxtFile2("test\\case1.txt");
            for (int i = 0; i < forCount; i++) {
              for (String src : testCases) {
                SegResult sr = SegMain.seg.split(src);
                count++;
                bytes+=src.getBytes().length;
                times+=sr.getSpendTime();
                jtSrcMsg.setText("total_count:"+count+"\ntotal_time:"+times+"\ntotal_bytes:"+bytes
                    +"\navg_time:"+(times/count)+"\navg_bytes:"+(bytes/times)+"b/ms");
                jtSplitMsg.setText("[time:" + sr.getSpendTime() + "ms]:\n" + sr.getFinalResult());
              }
            }
          } catch (IOException e1) {
            e1.printStackTrace();
          }
View Full Code Here

Examples of org.ictclas4j.bean.SegResult

//    SegMain sm = new SegMain();
    seg = new Segment(1);
//     sm.initFrm();
     String[] source = { "�ҵĹ�������һ��Ӱ¥����ױʦ���ص�λ�ڻƽ�ضΣ���Ϊ�Ҿ����������ϰ�����վ�������ɵ�����ʷ�Ϊ�������ʺ���������֣���������һ�㣬���ݹ������ͼ����ȼ�����ռ��ͷ�����ڹ˿ʹ���ĩ�пգ���һ������Ƚ����У���ĩ��æ����Ҫ�Ӱ࣬����ͨ����һ��Ϣ��" };
    for (int i = 0; i < source.length; i++) {
      SegResult sr = seg.split(source[i]);
      System.out.println("time:" + sr.getSpendTime() + " "
          + sr.getFinalResult());
      String [] ss =sr.getFinalResult().split("/\\w+ ");
      for (int j=0;j<ss.length;j++){
        System.out.println(ss[j]);
      }
    }
View Full Code Here

Examples of org.ictclas4j.bean.SegResult

    lexTagger = new PosTagger(Utility.TAG_TYPE.TT_NORMAL, "data\\lexical", coreDict);

  }

  public SegResult split(String src) {
    SegResult sr = new SegResult(src);// �ִʽ��
    String finalResult = null;

    if (src != null) {
      finalResult = "";
      int index = 0;
      String midResult = null;
      sr.setRawContent(src);
      SentenceSeg ss = new SentenceSeg(src);
      ArrayList<Sentence> sens = ss.getSens();
     
      for (Sentence sen : sens) {
       
        long start=System.currentTimeMillis();
        MidResult mr = new MidResult();
        mr.setIndex(index++);
        mr.setSource(sen.getContent());
        if (sen.isSeg()) {

          // ԭ�ӷִ�
          AtomSeg as = new AtomSeg(sen.getContent());
          ArrayList<Atom> atoms = as.getAtoms();
          mr.setAtoms(atoms);

          start=System.currentTimeMillis();
         
          // ���ɷִ�ͼ��,�Ƚ��г����ִʣ�Ȼ������Ż��������д��Ա��
          SegGraph segGraph = GraphGenerate.generate(atoms, coreDict);
          mr.setSegGraph(segGraph.getSnList());
          // ���ɶ���ִ�ͼ��
          SegGraph biSegGraph = GraphGenerate.biGenerate(segGraph, coreDict, bigramDict);
          mr.setBiSegGraph(biSegGraph.getSnList());

          start=System.currentTimeMillis();
         
          // ��N���·��
          NShortPath nsp = new NShortPath(biSegGraph, segPathCount);
          ArrayList<ArrayList<Integer>> bipath = nsp.getPaths();
          mr.setBipath(bipath);

          start=System.currentTimeMillis();
         
          for (ArrayList<Integer> onePath : bipath) {
            // �õ����ηִ�·��
            ArrayList<SegNode> segPath = getSegPath(segGraph, onePath);
            ArrayList<SegNode> firstPath = AdjustSeg.firstAdjust(segPath);
            String firstResult = outputResult(firstPath);
            mr.addFirstResult(firstResult);

            start=System.currentTimeMillis();

            // ����δ��½�ʣ����Գ��ηִʽ�������Ż�
            SegGraph optSegGraph = new SegGraph(firstPath);
            ArrayList<SegNode> sns = clone(firstPath);
            personTagger.recognition(optSegGraph, sns);
            transPersonTagger.recognition(optSegGraph, sns);
            placeTagger.recognition(optSegGraph, sns);
            mr.setOptSegGraph(optSegGraph.getSnList());
            start=System.currentTimeMillis();

            // �����Ż���Ľ�������½������ɶ���ִ�ͼ��
            SegGraph optBiSegGraph = GraphGenerate.biGenerate(optSegGraph, coreDict, bigramDict);
            mr.setOptBiSegGraph(optBiSegGraph.getSnList());

            // ������ȡN�����·��
            NShortPath optNsp = new NShortPath(optBiSegGraph, segPathCount);
            ArrayList<ArrayList<Integer>> optBipath = optNsp.getPaths();
            mr.setOptBipath(optBipath);

            // �����Ż���ķִʽ�������Խ�����д��Ա�Ǻ������Ż���������
            ArrayList<SegNode> adjResult = null;
            for (ArrayList<Integer> optOnePath : optBipath) {
              ArrayList<SegNode> optSegPath = getSegPath(optSegGraph, optOnePath);
              lexTagger.recognition(optSegPath);
              String optResult = outputResult(optSegPath);
              mr.addOptResult(optResult);
              adjResult = AdjustSeg.finaAdjust(optSegPath, personTagger, placeTagger);
              String adjrs = outputResult(adjResult);
              start=System.currentTimeMillis();
              if (midResult == null)
                midResult = adjrs;
              break;
            }
          }
          sr.addMidResult(mr);
        } else
          midResult = sen.getContent();
        finalResult += midResult;
        midResult = null;
      }

      sr.setFinalResult(finalResult);

    }

    return sr;
  }
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.