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


Java MaltChainedException类代码示例

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


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

示例1: copyPartialDependencyStructure

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public void copyPartialDependencyStructure(DependencyStructure sourceGraph, DependencyStructure targetGraph) throws MaltChainedException {
	SymbolTable partHead = cachedSource.getSymbolTables().getSymbolTable("PARTHEAD");
	SymbolTable partDeprel = cachedSource.getSymbolTables().getSymbolTable("PARTDEPREL");
	if (partHead == null || partDeprel == null) {
		return;
	}
	SymbolTable deprel = cachedTarget.getSymbolTables().getSymbolTable("DEPREL");
	for (int index : sourceGraph.getTokenIndices()) {
		DependencyNode snode = sourceGraph.getTokenNode(index);
		DependencyNode tnode = targetGraph.getTokenNode(index);
		if (snode != null && tnode != null) {
			int spartheadindex = Integer.parseInt(snode.getLabelSymbol(partHead));
			String spartdeprel = snode.getLabelSymbol(partDeprel);
			if (spartheadindex > 0) {
				Edge tedge = targetGraph.addDependencyEdge(spartheadindex, snode.getIndex());
				tedge.addLabel(deprel, spartdeprel);
			}
		}
	}
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:21,代码来源:CopyChartItem.java

示例2: LWDeterministicParser

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public LWDeterministicParser(LWSingleMalt lwSingleMalt, SymbolTableHandler symbolTableHandler, FeatureModel _featureModel) throws MaltChainedException {
	this.manager = lwSingleMalt;
	this.registry = new ParserRegistry();
	this.registry.setSymbolTableHandler(symbolTableHandler);
	this.registry.setDataFormatInstance(manager.getDataFormatInstance());
	this.registry.setAbstractParserFeatureFactory(manager.getParserFactory());
	this.registry.setAlgorithm(this);
	this.transitionSystem = manager.getParserFactory().makeTransitionSystem();
	this.transitionSystem.initTableHandlers(lwSingleMalt.getDecisionSettings(), symbolTableHandler);
	
	this.tableHandlers = transitionSystem.getTableHandlers();
	this.kBestSize = lwSingleMalt.getkBestSize();
	this.decisionTables = new ArrayList<TableContainer>();
	this.actionTables = new ArrayList<TableContainer>();
	initDecisionSettings(lwSingleMalt.getDecisionSettings(), lwSingleMalt.getClassitem_separator());
	this.transitionSystem.initTransitionSystem(this);
	this.config = manager.getParserFactory().makeParserConfiguration();
	this.featureModel = _featureModel;
	this.currentAction = new ComplexDecisionAction(this);
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:21,代码来源:LWDeterministicParser.java

示例3: moveDependencyEdge

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public Edge moveDependencyEdge(DependencyNode newHead, DependencyNode dependent) throws MaltChainedException {
	if (dependent == null || !dependent.hasHead() || newHead.getBelongsToGraph() != this || dependent.getBelongsToGraph() != this) {
		return null;
	}
	Edge headEdge = dependent.getHeadEdge();

	LabelSet labels = null;
	if (headEdge.isLabeled()) { 
		labels = checkOutNewLabelSet();
		for (SymbolTable table : headEdge.getLabelTypes()) {
			labels.put(table, headEdge.getLabelCode(table));
		}
	}
	headEdge.clear();
	headEdge.setBelongsToGraph(this);
	headEdge.setEdge((Node)newHead, (Node)dependent, Edge.DEPENDENCY_EDGE);
	if (labels != null) {
		headEdge.addLabel(labels);
		labels.clear();
		checkInLabelSet(labels);
	}
	return headEdge;
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:24,代码来源:MappablePhraseStructureGraph.java

示例4: initialize

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public void initialize(Object[] arguments) throws MaltChainedException {
	if (arguments.length != 2) {
		throw new SyntaxGraphException("Could not initialize OutputColumnFeature: number of arguments are not correct. ");
	}
	if (!(arguments[0] instanceof String)) {
		throw new SyntaxGraphException("Could not initialize OutputColumnFeature: the first argument is not a string. ");
	}
	if (!(arguments[1] instanceof AddressFunction)) {
		throw new SyntaxGraphException("Could not initialize OutputColumnFeature: the second argument is not an address function. ");
	}
	ColumnDescription column = dataFormatInstance.getColumnDescriptionByName((String)arguments[0]);
	if (column == null) {
		throw new SyntaxGraphException("Could not initialize OutputColumnFeature: the output column type '"+(String)arguments[0]+"' could not be found in the data format specification. ' ");
	}
	setColumn(column);
	setSymbolTable(tableHandler.getSymbolTable(column.getName()));
	setAddressFunction((AddressFunction)arguments[1]);
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:19,代码来源:OutputColumnFeature.java

示例5: addSymbol

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public int addSymbol(String symbol) throws MaltChainedException {
	if (nullValues == null || !nullValues.isNullValue(symbol)) {
		if (symbol == null || symbol.length() == 0) {
			throw new SymbolException("Symbol table error: empty string cannot be added to the symbol table");
		}

		if (this.type == SymbolTable.REAL) {
			addSymbolValue(symbol);
		}
		if (!symbolCodeMap.containsKey(symbol)) {
			int code = valueCounter;
			symbolCodeMap.put(symbol, code);
			codeSymbolMap.put(code, symbol);
			valueCounter++;
			return code;
		} else {
			return symbolCodeMap.get(symbol);
		}
	} else {
		return nullValues.symbolToCode(symbol);
	}
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:23,代码来源:HashSymbolTable.java

示例6: loadFeatureModelManager

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
private FeatureModelManager loadFeatureModelManager(int optionContainer, McoModel mcoModel) throws MaltChainedException {
	final FeatureEngine system = new FeatureEngine();
	system.load("/appdata/features/ParserFeatureSystem.xml");
	system.load(PluginLoader.instance());
	FeatureModelManager featureModelManager = new FeatureModelManager(system);
	String featureModelFileName = OptionManager.instance().getOptionValue(optionContainer, "guide", "features").toString().trim();
	try {
		if (featureModelFileName.endsWith(".par")) {
			String markingStrategy = OptionManager.instance().getOptionValue(optionContainer, "pproj", "marking_strategy").toString().trim();
			String coveredRoot = OptionManager.instance().getOptionValue(optionContainer, "pproj", "covered_root").toString().trim();
			featureModelManager.loadParSpecification(mcoModel.getMcoEntryURL(featureModelFileName), markingStrategy, coveredRoot);
		} else {
			featureModelManager.loadSpecification(mcoModel.getMcoEntryURL(featureModelFileName));
		}
	} catch(IOException e) {
		throw new MaltChainedException("Couldn't read file "+featureModelFileName+" from mco-file ", e);
	}
	return featureModelManager;
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:20,代码来源:ConcurrentMaltParserModel.java

示例7: updateActionContainers

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
protected GuideUserAction updateActionContainers(int transition, LabelSet arcLabels) throws MaltChainedException {	
	transActionContainer.setAction(transition);

	if (arcLabels == null) {
		for (int i = 0; i < arcLabelActionContainers.length; i++) {
			arcLabelActionContainers[i].setAction(-1);	
		}
	} else {
		for (int i = 0; i < arcLabelActionContainers.length; i++) {
			arcLabelActionContainers[i].setAction(arcLabels.get(arcLabelActionContainers[i].getTable()).shortValue());
		}		
	}
	GuideUserAction oracleAction = history.getEmptyGuideUserAction();
	oracleAction.addAction(actionContainers);
	return oracleAction;
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:17,代码来源:Oracle.java

示例8: initialize

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public void initialize(Object[] arguments) throws MaltChainedException {
	if (arguments.length != 3) {
		throw new FeatureException("Could not initialize InputArcFeature: number of arguments are not correct. ");
	}
	// Checks that the two arguments are address functions

	if (!(arguments[0] instanceof String)) {
		throw new FeatureException("Could not initialize InputArcFeature: the first argument is not a string. ");
	}
	if (!(arguments[1] instanceof AddressFunction)) {
		throw new SyntaxGraphException("Could not initialize InputArcFeature: the second argument is not an address function. ");
	}
	if (!(arguments[2] instanceof AddressFunction)) {
		throw new SyntaxGraphException("Could not initialize InputArcFeature: the third argument is not an address function. ");
	}
	setAddressFunction1((AddressFunction)arguments[1]);
	setAddressFunction2((AddressFunction)arguments[2]);
	
	setColumn(dataFormatInstance.getColumnDescriptionByName((String)arguments[0]));
	setSymbolTable(tableHandler.addSymbolTable("ARC_"+column.getName(),ColumnDescription.INPUT, ColumnDescription.STRING, "one"));
	table.addSymbol("LEFT");
	table.addSymbol("RIGHT");
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:24,代码来源:InputArcFeature.java

示例9: getRightmostProperDescendant

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
@Override
public ComparableNode getRightmostProperDescendant() throws MaltChainedException {
	ComparableNode candidate = null;
	List<DependencyNode> dependents = graph.getListOfDependents(index);
	for (int i = 0; i < dependents.size(); i++) {
		final DependencyNode dep = dependents.get(i);
		if (candidate == null || dep.getIndex() > candidate.getIndex()) {
			candidate = dep;
		}
		final ComparableNode tmp = dep.getRightmostProperDescendant();
		if (tmp == null) {
			continue;
		}
		if (candidate == null || tmp.getIndex() > candidate.getIndex()) {
			candidate = tmp;
		}
	}
	return candidate;
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:20,代码来源:LWNode.java

示例10: deprojectivizeWithHeadAndPath

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
private boolean deprojectivizeWithHeadAndPath(DependencyStructure pdg, DependencyNode node, boolean[] nodeLifted, boolean[] nodePath, String[] synacticHeadDeprel, SymbolTable deprelSymbolTable) throws MaltChainedException {
	boolean success = true, childSuccess = false;
	int i, childAttempts = 2;
	DependencyNode possibleSyntacticHead;
	if (node.hasHead() && node.getHeadEdge().isLabeled() && nodeLifted[node.getIndex()] && nodePath[node.getIndex()]) {
		possibleSyntacticHead = breadthFirstSearchSortedByDistanceForHeadAndPath(pdg, node.getHead(), node, synacticHeadDeprel[node.getIndex()], nodePath, deprelSymbolTable);
		if (possibleSyntacticHead != null) {
			pdg.moveDependencyEdge(possibleSyntacticHead.getIndex(), node.getIndex());
			nodeLifted[node.getIndex()] = false;
		} else {
			success = false;
		}
	}
	if (node.hasHead() && node.getHeadEdge().isLabeled() && nodeLifted[node.getIndex()]) {
		possibleSyntacticHead = breadthFirstSearchSortedByDistanceForHeadAndPath(pdg, node.getHead(), node, synacticHeadDeprel[node.getIndex()], nodePath, deprelSymbolTable);
		if (possibleSyntacticHead != null) {
			pdg.moveDependencyEdge(possibleSyntacticHead.getIndex(), node.getIndex());
			nodeLifted[node.getIndex()] = false;
		} else {
			success = false;
		}
	}
	while (!childSuccess && childAttempts > 0) {
		childSuccess = true;
		List<DependencyNode> children = node.getListOfDependents();
		for (i = 0; i < children.size(); i++) {
			if (!deprojectivizeWithHeadAndPath(pdg, children.get(i), nodeLifted, nodePath, synacticHeadDeprel, deprelSymbolTable)) {
				childSuccess = false;
			}
		}
		childAttempts--;
	}
	return childSuccess && success;
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:35,代码来源:LWDeprojectivizer.java

示例11: addSecondaryEdge

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public Edge addSecondaryEdge(ComparableNode source, ComparableNode target) throws MaltChainedException {
	if (source == null || target == null || source.getBelongsToGraph() != this || target.getBelongsToGraph() != this) {
		throw new SyntaxGraphException("Head or dependent node is missing.");
	} else if (!target.isRoot()) {
		Edge e = edgePool.checkOut();
		e.setBelongsToGraph(this);
		e.setEdge((Node)source, (Node)target, Edge.SECONDARY_EDGE);
		graphEdges.add(e);
		return e;
	}
	return null;
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:13,代码来源:MappablePhraseStructureGraph.java

示例12: checkInAll

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public synchronized void checkInAll() throws MaltChainedException {
	for (T t : inuse) {
		resetObject(t);
		if (available.size() < keepThreshold) {
			available.add(t);
		}
	}
	inuse.clear();
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:10,代码来源:ObjectPoolSet.java

示例13: setUsage

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
/**
 * Sets the usage of the option.
 * 
 * @param usage	the usage of the option.
 * @throws OptionException
 */
public void setUsage(int usage) throws MaltChainedException {
	if (usage >= 0 && usage <= 4) {
		this.usage = usage;
	} else {
		throw new OptionException("Illegal use of the usage attibute value: "+usage+" for the '"+getName()+"' option. ");
	}
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:14,代码来源:Option.java

示例14: getCode

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public int getCode(String symbol) throws MaltChainedException {
	if (cachedSymbol == null || !cachedSymbol.equals(symbol)) {
		clearCache();
		cachedSymbol.append(symbol);
		cachedCode = table.getSymbolStringToCode(symbol);
		split();
	}
	return cachedCode;
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:10,代码来源:CombinedTableContainer.java

示例15: writeSentence

import org.maltparser.core.exception.MaltChainedException; //导入依赖的package包/类
public void writeSentence(TokenStructure syntaxGraph) throws MaltChainedException {
	if (syntaxGraph == null || dataFormatInstance == null || !(syntaxGraph instanceof PhraseStructure) || !syntaxGraph.hasTokens()) {
		return;
	}
	PhraseStructure phraseStructure = (PhraseStructure)syntaxGraph;
	sentenceCount++;
	try {
		writer.write("#BOS ");
		if (phraseStructure.getSentenceID() != 0) {
			writer.write(Integer.toString(phraseStructure.getSentenceID()));
		} else {
			writer.write(Integer.toString(sentenceCount));
		}
		writer.write('\n');

		if (phraseStructure.hasNonTerminals()) {
			calculateIndices(phraseStructure);
			writeTerminals(phraseStructure);
			writeNonTerminals(phraseStructure);
		} else {
			writeTerminals(phraseStructure);
		}
		writer.write("#EOS ");
		if (phraseStructure.getSentenceID() != 0) {
			writer.write(Integer.toString(phraseStructure.getSentenceID()));
		} else {
			writer.write(Integer.toString(sentenceCount));
		}
		writer.write('\n');
	} catch (IOException e) {
		throw new DataFormatException("Could not write to the output file. ", e);
	}
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:34,代码来源:NegraWriter.java


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