当前位置: 首页>>代码示例>>Java>>正文


Java UnaryRule类代码示例

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


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

示例1: increment

import edu.berkeley.nlp.PCFGLA.UnaryRule; //导入依赖的package包/类
public void increment(double[] counts, UnaryRule rule, double[] weights,
		boolean isGold) {
	int thisStartIndex = rule.identifier;
	int curInd = 0;
	int nSubstatesParent = (rule.parentState == 0) ? 1 : nSubstates;
	for (int cp = 0; cp < nSubstates; cp++) {
		// if (scores[cp]==null) continue;
		for (int np = 0; np < nSubstatesParent; np++) {
			if (isGold)
				counts[thisStartIndex++] += weights[curInd];
			else
				counts[thisStartIndex++] -= weights[curInd];
			weights[curInd++] = 0;
		}
	}
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:17,代码来源:DefaultLinearizer.java

示例2: testSmooth

import edu.berkeley.nlp.PCFGLA.UnaryRule; //导入依赖的package包/类
public void testSmooth() {
	short pState = 1, lState = 2, rState = 3;
	short[] numSubStates = { 3, 3, 3, 3 };
	double[][] uScores = { { 1, 0, 0 }, { 1, 1, 1 }, { 0, 0, 1 } };
	double[][] targetUScores = { { 0.75, 0.25, 0.5 }, { 0.75, 0.5, 0.75 },
			{ 0.5, 0.25, 0.75 } };
	double[][][] bScores = { { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } },
			{ { 0, 1, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
			{ { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } } };
	double[][][] targetBScores = {
			{ { 0.5, 0.25, 0 }, { 0, 0.5, 0 }, { 0, 0, 0.5 } },
			{ { 0.25, 0.5, 0 }, { 0, 0.25, 0 }, { 0, 0, 0.25 } },
			{ { 0.25, 0.25, 0 }, { 0, 0.25, 0 }, { 0, 0, 0.25 } } };

	UnaryRule ur = new UnaryRule(pState, lState, uScores);
	BinaryRule br = new BinaryRule(pState, lState, rState, bScores);
	Smoother sm = new SmoothAcrossParentSubstate(0.5);
	UnaryCounterTable unaryCounter = new UnaryCounterTable(numSubStates);
	unaryCounter.setCount(ur, uScores);
	BinaryCounterTable binaryCounter = new BinaryCounterTable(numSubStates);
	binaryCounter.setCount(br, bScores);
	sm.smooth(unaryCounter, binaryCounter);

	double[][] newUScores = unaryCounter.getCount(ur);
	for (int i = 0; i < newUScores.length; i++) {
		for (int j = 0; j < newUScores[i].length; j++) {
			// assertEquals(newUScores[i][j],targetUScores[i][j],0.0001);
		}
	}
	double[][][] newBScores = binaryCounter.getCount(br);
	for (int i = 0; i < newBScores.length; i++) {
		for (int j = 0; j < newBScores[i].length; j++) {
			for (int k = 0; k < newBScores[i][j].length; k++) {
				// assertEquals(newBScores[i][j][k],targetBScores[i][j][k],0.0001);
			}
		}
	}
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:39,代码来源:SmoothAcrossParentSubstateTest.java

示例3: increment

import edu.berkeley.nlp.PCFGLA.UnaryRule; //导入依赖的package包/类
public void increment(double[] counts, UnaryRule rule, double[] weights,
boolean isGold);
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:3,代码来源:Linearizer.java


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