• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SentenceData09类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中is2.data.SentenceData09的典型用法代码示例。如果您正苦于以下问题:Java SentenceData09类的具体用法?Java SentenceData09怎么用?Java SentenceData09使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SentenceData09类属于is2.data包,在下文中一共展示了SentenceData09类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getSemEdge

import is2.data.SentenceData09; //导入依赖的package包/类
/**
 * @param i
 * @param n
 * @param p
 * @param l
 */
public static Edge getSemEdge(SentenceData09 i, int n, int p, String l) {

	StringBuffer key = new StringBuffer();
	key.append(l);

//	Edge e = null;
	Edge e = mappingList.get(key.toString());
	key.append('*').append(i.gpos[n]);
	
	// take the more specific
	Edge e1 = mappingList.get(key.toString());
	if (e1!=null) e=e1;
	
	
	if (e==null) {
		e = new Edge (true,"A");
		DB.println("found no mapping for "+i.gpos[p]+" "+l+" -> "+i.gpos[n]+" forms "+i.forms[p]+" "+l+" -> "+i.forms[n] );
		notConnectedCount++;
	} 
	return e;
	
	
}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:30,代码来源:Semantic.java


示例2: getPath

import is2.data.SentenceData09; //导入依赖的package包/类
private ArrayList<Integer> getPath(int s1, int s2, SentenceData09 sure) {

		ArrayList<Integer> p = new ArrayList<Integer>();
		
		int h = s2;;
		p.add(h);
		while(true) {
			
			h = sure.heads[h];
			p.add(h);
			if (h==s1) break;
			if (p.size()>3) {
				System.out.println("path not found "+p);
				p.clear();
				break;
			}
		}
		
		
		return p;
	}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:22,代码来源:Pipe.java


示例3: main

import is2.data.SentenceData09; //导入依赖的package包/类
public static void main(String[] args) throws Exception{
	
	File desegmentedInput=new File("chi-desegmented.out");
	Tokenizer tokenizer=new StanfordChineseSegmenterWrapper(new File("/home/anders/Download/stanford-chinese-segmenter-2008-05-21/data"));
	Lemmatizer lemmatizer=new SimpleChineseLemmatizer();
	Tagger tagger=BohnetHelper.getTagger(new File("models/chi/tag-chn.model"));
	Preprocessor pp=new Preprocessor(tokenizer,lemmatizer,tagger,null,null);
	BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(desegmentedInput),"UTF-8"));
	String line;
	while((line=reader.readLine())!=null){
		String[] tokens=pp.tokenize(line);
		SentenceData09 s=pp.preprocess(tokens);
		System.out.println(s);
	}

}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:17,代码来源:Preprocessor.java


示例4: Sentence

import is2.data.SentenceData09; //导入依赖的package包/类
public Sentence(SentenceData09 data, boolean skipTree) {
	this();
	int offset = 0;
	if (data.pheads[0] == -1)
		offset++;
	for (int i = 0 + offset; i < data.forms.length; ++i) {
		Word nextWord = new Word(data.forms[i], data.plemmas[i],
				data.ppos[i], data.pfeats[i], this, i + 1 - offset);
		super.add(nextWord);
	}
	if (skipTree)
		return;
	for (int i = 0; i < data.forms.length - offset; ++i) {
		Word curWord = super.get(i + 1);
		curWord.setHead(super.get(data.pheads[i + offset]));
		curWord.setDeprel(data.plabels[i + offset]);
	}
	this.buildDependencyTree();
}
 
开发者ID:microth,项目名称:mateplus,代码行数:20,代码来源:Sentence.java


示例5: nextInstance

import is2.data.SentenceData09; //导入依赖的package包/类
/**
 * Creates an instance for outputParses
 * 
 * @param is
 * @return
 * @throws IOException
 */
protected final SentenceData09 nextInstance(Instances is, CONLLReader09 depReader) throws Exception {

	SentenceData09 instance = depReader.getNext(is);
	if (instance == null || instance.forms == null)	return null;

	return instance;
}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:15,代码来源:Pipe.java


示例6: Word

import is2.data.SentenceData09; //导入依赖的package包/类
public Word(SentenceData09 i, int k, String ft ) {
	form = i.forms[k];
	lemma = i.lemmas[k];
	gpos = i.gpos[k];
	ppos = i.ppos[k];
	lable =i.labels[k];
	if (ft!=null)feats ="id="+k+(ft.length()>0?"|"+ft:"");
}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:9,代码来源:DSyntConverter.java


示例7: getChilds

import is2.data.SentenceData09; //导入依赖的package包/类
/**
 * @param r
 * @param d
 * @return
 */
public ArrayList<Integer> getChilds(int h, SentenceData09 d) {

	ArrayList<Integer> cs = new ArrayList<Integer>();
	for(int i=0;i<d.length();i++) {

		if (d.heads[i]==h) cs.add(i);

	}
	return cs;
}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:16,代码来源:Pipe.java


示例8: getLeafs

import is2.data.SentenceData09; //导入依赖的package包/类
/**
 * Get all leafs
 * @param ds
 * @return
 */
public int[] getLeafs(SentenceData09 ds) {

	// count the leafs
	int leafCount=0;
	for(int i=0;i<ds.length();i++) 	if (!hasChild(i,ds)) leafCount++;
	
	int leafs[] = new int[leafCount];
	leafCount=0;
	for(int i=0;i<ds.length();i++) 	{
		if (!hasChild(i,ds)) leafs[leafCount++]=i;	
	}
	
	return leafs;
}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:20,代码来源:Pipe.java


示例9: hasChild

import is2.data.SentenceData09; //导入依赖的package包/类
/**
 * Has n at least one child?
 * @param n
 * @param ds
 * @return
 */
private boolean hasChild(int n, SentenceData09 ds) {

	for(int i=ds.length()-1;i>=0;i--) {
		if (ds.heads[i]==n) return true;
	}
	return false;
}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:14,代码来源:Pipe.java


示例10: tag

import is2.data.SentenceData09; //导入依赖的package包/类
public SentenceData09 tag(SentenceData09 instance, OptionsSuper options){
	InstancesTagger is = new InstancesTagger();
	is.init(1, pipe.mf);
	new CONLLReader09().insert(is, instance);
	is.fillChars(instance, 0, Pipe._CEND);
	tag(is, instance,options.stack);

	return instance;
}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:10,代码来源:Tagger.java


示例11: getChildren

import is2.data.SentenceData09; //导入依赖的package包/类
public static ArrayList<ID> getChildren(SentenceData09 instance, int head) {

		ArrayList<ID> children = new ArrayList<ID>();
		for(int i=0;i<instance.length();i++) {
			
			if (instance.heads[i]==head) {
				String id = instance.id[i];
				if (id.contains("_")) {
					id = id.split("_")[1];
				}
				children.add(new ID(id,i));
			}
		}
		return children;
	}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:16,代码来源:Evaluator.java


示例12: apply

import is2.data.SentenceData09; //导入依赖的package包/类
@Override
public SentenceData09 apply(SentenceData09 instance) {
	for(int i=0;i<instance.forms.length;++i)
		instance.plemmas[i]=instance.forms[i];
	
	return instance;
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:8,代码来源:SimpleChineseLemmatizer.java


示例13: Sentence

import is2.data.SentenceData09; //导入依赖的package包/类
public Sentence(SentenceData09 data){
	this();
	for(int i=0;i<data.forms.length;++i){
		Word nextWord=new Word(data.forms[i],data.plemmas[i],data.ppos[i],data.pfeats[i],this,i+1);
		super.add(nextWord);
	}
	for(int i=0;i<data.forms.length;++i){
		Word curWord=super.get(i+1);
		curWord.setHead(super.get(data.pheads[i]));
		curWord.setDeprel(data.plabels[i]);
	}
	this.buildDependencyTree();
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:14,代码来源:Sentence.java


示例14: parseX

import is2.data.SentenceData09; //导入依赖的package包/类
public Sentence parseX(List<StringInText> words) throws Exception {
	String[] array = new String[words.size()];
	for (int i = 0; i < array.length; i++)
		array[i] = words.get(i).word();
	SentenceData09 tmp = pp.preprocess(array);
	Sentence s = new Sentence(tmp, false);
	for (int i = 0; i < array.length; i++) {
		s.get(i).setBegin(words.get(i).begin());
		s.get(i).setEnd(words.get(i).end());
	}
	srl.parse(s);
	return s;
}
 
开发者ID:microth,项目名称:mateplus,代码行数:14,代码来源:CompletePipeline.java


示例15: apply

import is2.data.SentenceData09; //导入依赖的package包/类
@Override
public SentenceData09 apply(SentenceData09 instance) {
	for (int i = 0; i < instance.forms.length; ++i)
		instance.plemmas[i] = instance.forms[i];

	return instance;
}
 
开发者ID:microth,项目名称:mateplus,代码行数:8,代码来源:SimpleChineseLemmatizer.java


示例16: preprocess

import is2.data.SentenceData09; //导入依赖的package包/类
@Override
protected SentenceData09 preprocess(SentenceData09 sentence) {
	if (lemmatizer != null) {
		long start = System.currentTimeMillis();
		sentence = lemmatizer.apply(sentence);
		lemmatizeTime += System.currentTimeMillis() - start;
	}
	return parser.apply(sentence);
}
 
开发者ID:microth,项目名称:mateplus,代码行数:10,代码来源:HybridPreprocessor.java


示例17: getSemEdge

import is2.data.SentenceData09; //导入依赖的package包/类
public static Edge getSemEdge(SentenceData09 i, int n, int p, String l) {
	
	StringBuffer key = new StringBuffer();
	key.append(l);

//	Edge e = null;
	Edge e = mappingList.get(key.toString());

	
	
	key.append('*').append(i.gpos[n]);

	// take the more specific
	Edge e1 = mappingList.get(key.toString());
	if (e1!=null) return e1;

	key = new StringBuffer();
	key.append(l).append('@').append(i.gpos[p]);

	// find head 
	Edge e2 = mappingList.get(key.toString());
	if (e2!=null) return e2;
	
	return e;	
}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:26,代码来源:DSyntConverter.java


示例18: getSemEdge

import is2.data.SentenceData09; //导入依赖的package包/类
public static Edge getSemEdge(SentenceData09 i, int n, int p, String l) {

		StringBuffer key = new StringBuffer();
		key.append(l);

		//	Edge e = null;
		Edge e = mappingList.get(key.toString());


		key.append('*').append(i.gpos[n]);

		// take the more specific
		Edge e1 = mappingList.get(key.toString());
		if (e1!=null) return e1;

		key = new StringBuffer();
		key.append(l).append('@').append(i.gpos[p]);

		// find head 
		Edge e2 = mappingList.get(key.toString());
		if (e2!=null) return e2;

		return e;	
	}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:25,代码来源:SemConverter.java


示例19: writeFeatures

import is2.data.SentenceData09; //导入依赖的package包/类
/**
	 * @param options2
	 */
	public void writeFeatures(Options options2) {


		try {
			BufferedWriter br = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(options2.writeSVM),"UTF8"));

			CONLLReader09 depReader = new CONLLReader09(CONLLReader09.NO_NORMALIZE);

			depReader.startReading(options2.testfile);

			DB.println("write features"+options2.writeSVM);
			
			InstancesTagger is = new InstancesTagger();

			is.init(options2.count+2, mf);

			int num1=0,del=0;
			
			while(true) {
			
			//	if (num1 % 100 ==0) 
					del = outValue(num1, del);

				SentenceData09 instance1 = depReader.getNext(is);
				if (instance1== null) break;

				is.fillChars(instance1, num1,_CEND);
//				for(int k=0;k<instance1.length();k++) {
//					if (instance1.ppos[k].contains("\\|"))  
//						is.pposs[num1][k] = (short)mf.getValue(FM, instance1.ppos[k].split("\\|")[1]);
//				}

				// create features 
				for (int k=0;k<instance1.length();k++) {
					long[] vs = new long[65];
					long[] vs2 = new long[65];

					int fx =this.addFeatures(is, num1, instance1.forms[k], k, is.forms[num1], is.plemmas[num1], vs);
					
					
					this.addFeatPos(is, num1, k, is.pposs[num1], is.forms[num1], fx, vs2, STACK); 
					//(is, num1, instance1.forms[k], k, is.forms[num1], is.plemmas[num1], vs);

					StringBuilder b = new StringBuilder();
					b.append(instance1.gpos[k]).append(' ');

					//			int l = is.gpos[num1][k]<<is2.tokenizer.Pipe.s_type;
					for(int f=0; f<vs.length;f++ ) {
						if (vs[f]==Integer.MIN_VALUE) break;
						if (vs[f]<=0 ) continue;
						b.append(vs[f]).append(':').append('1').append(' ');
					}
					
					for(int f=0; f<vs2.length;f++ ) {
						if (vs2[f]==Integer.MIN_VALUE) break;
						if (vs2[f]<=0 ) continue;
						b.append(vs2[f]).append(':').append('1').append(' ');
					}
					br.write(b.toString());
					if (num1<=options.count+1) br.newLine();
					//System.out.println(b.toString());	
				}

				if (num1>options.count) break;
				num1++;
			}
			DB.println("finnished writting");

			br.close();
		} catch(Exception e) {
			e.printStackTrace();
		}
	
	}
 
开发者ID:matxin,项目名称:matxin-lineariser,代码行数:78,代码来源:Pipe.java



注:本文中的is2.data.SentenceData09类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WellKnownFolderName类代码示例发布时间:2022-05-22
下一篇:
Java IRIResolver类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap