ProbEdge.java
资源名称:Parsing.rar [点击查看]
上传用户:xiaozhuqw
上传日期:2021-11-10
资源大小:21k
文件大小:2k
源码类别:
词法分析
开发平台:
Java
- import java.io.*;
- import java.util.*;
- public class ProbEdge extends Edge {
- //public int ruleId; // 所用规则的序号
- //public String parent;// 更大局部分析的序号集
- public double insideProb; //outsideProb;// 内部概率,内部概率之和,外部概率
- public int pId; //该局部分析在局部分析表中的位置
- public Vector child; //孩子结点的位置
- public ProbEdge() {
- }
- public ProbEdge(String wt, int wid, int pId) {
- super(wt, wid);
- insideProb = 1.0;
- //ruleId = -1;
- this.pId = pId;
- this.child = new Vector();
- //outsideProb = 0.0;
- //parent = new String();
- }
- public ProbEdge(List edgeList, Value value, int pId){
- //ProbRules r = (ProbRules)rules.get(rId);
- ProbEdge e;
- //int index;
- //this.ruleId = rId;
- //this.outsideProb = 0.0;
- //this.parent = new String();
- this.root = value.ls;
- this.first = ((ProbEdge)edgeList.get(0)).first;
- this.last = ((ProbEdge)edgeList.get(edgeList.size() - 1)).last;
- this.insideProb = value.prob;
- this.child = new Vector();
- for(int i = 0;i<edgeList.size();i++){
- e = (ProbEdge)edgeList.get(i);
- this.insideProb *= e.insideProb;
- this.child.add(new Integer(e.pId));
- }
- //this.inProbAddUp = this.insideProb;
- this.pId = pId;
- }
- public ProbEdge(ProbEdge p, Value value, int pId) {
- //ProbRules r = (ProbRules) rules.get(rId);
- //this.ruleId = rId;
- //this.outsideProb = 0.0;
- //this.parent = new String();
- this.root = value.ls;
- this.first = p.first;
- this.last = p.last;
- //this.sub1 = pId;
- //this.sub2 = -1;
- this.insideProb = value.prob * p.insideProb;
- this.pId = pId;
- this.child = new Vector();
- this.child.add(new Integer(p.pId));
- }
- public static void main(String[] args){
- Vector vec = new Vector();
- if(vec.isEmpty())
- System.out.println("empty");
- }
- }