| package org.maltparser.parser;
|
|
|
| import org.maltparser.core.exception.MaltChainedException;
|
| import org.maltparser.core.symbol.SymbolTable;
|
| import org.maltparser.core.symbol.SymbolTableHandler;
|
| import org.maltparser.core.syntaxgraph.DependencyStructure;
|
| import org.maltparser.core.syntaxgraph.edge.Edge;
|
| import org.maltparser.core.syntaxgraph.node.DependencyNode;
|
| import org.maltparser.parser.guide.ClassifierGuide;
|
| |
| |
| |
|
|
| public abstract class ParsingAlgorithm implements AlgoritmInterface {
|
| protected final DependencyParserConfig manager;
|
| protected final ParserRegistry registry;
|
| protected ClassifierGuide classifierGuide;
|
| protected final ParserState parserState;
|
| protected ParserConfiguration currentParserConfiguration;
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| public ParsingAlgorithm(DependencyParserConfig _manager, SymbolTableHandler symbolTableHandler) throws MaltChainedException {
|
| this.manager = _manager;
|
| this.registry = new ParserRegistry();
|
| registry.setSymbolTableHandler(symbolTableHandler);
|
| registry.setDataFormatInstance(manager.getDataFormatInstance());
|
| registry.setAbstractParserFeatureFactory(manager.getParserFactory());
|
| parserState = new ParserState(manager, symbolTableHandler, manager.getParserFactory());
|
| }
|
|
|
| public abstract void terminate() throws MaltChainedException;
|
|
|
| public ParserRegistry getParserRegistry() {
|
| return registry;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public ClassifierGuide getGuide() {
|
| return classifierGuide;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public void setGuide(ClassifierGuide guide) {
|
| this.classifierGuide = guide;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public ParserConfiguration getCurrentParserConfiguration() {
|
| return currentParserConfiguration;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| protected void setCurrentParserConfiguration(ParserConfiguration currentParserConfiguration) {
|
| this.currentParserConfiguration = currentParserConfiguration;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public ParserState getParserState() {
|
| return parserState;
|
| }
|
|
|
|
|
| |
| |
| |
| |
|
|
| public DependencyParserConfig getManager() {
|
| return manager;
|
| }
|
|
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| protected void copyEdges(DependencyStructure source, DependencyStructure target) throws MaltChainedException {
|
| for (int index : source.getTokenIndices()) {
|
| DependencyNode snode = source.getDependencyNode(index);
|
|
|
| if (snode.hasHead()) {
|
| Edge s = snode.getHeadEdge();
|
| Edge t = target.addDependencyEdge(s.getSource().getIndex(), s.getTarget().getIndex());
|
|
|
| for (SymbolTable table : s.getLabelTypes()) {
|
| t.addLabel(table, s.getLabelSymbol(table));
|
| }
|
| }
|
| }
|
| }
|
|
|
| protected void copyDynamicInput(DependencyStructure source, DependencyStructure target) throws MaltChainedException {
|
| for (int index : source.getTokenIndices()) {
|
| DependencyNode snode = source.getDependencyNode(index);
|
| DependencyNode tnode = target.getDependencyNode(index);
|
| for (SymbolTable table : snode.getLabelTypes()) {
|
| if (!tnode.hasLabel(table)) {
|
| tnode.addLabel(table,snode.getLabelSymbol(table));
|
| }
|
| }
|
| }
|
| }
|
| }
|
|
|