diff --git a/LVTB2UD/src/lv/ailab/lvtb/universalizer/pml/xmldom/XmlDomANode.java b/LVTB2UD/src/lv/ailab/lvtb/universalizer/pml/xmldom/XmlDomANode.java index e5c071c4..f2a9b1f4 100644 --- a/LVTB2UD/src/lv/ailab/lvtb/universalizer/pml/xmldom/XmlDomANode.java +++ b/LVTB2UD/src/lv/ailab/lvtb/universalizer/pml/xmldom/XmlDomANode.java @@ -6,6 +6,7 @@ import lv.ailab.lvtb.universalizer.pml.PmlANode; import lv.ailab.lvtb.universalizer.pml.utils.PmlANodeListUtils; import lv.ailab.lvtb.universalizer.transformator.morpho.AnalyzerWrapper; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -739,17 +740,20 @@ public boolean splitMorphoEllipsis(String idPostfix) if (reductionField == null || reductionField.isEmpty()) return false; try { + XmlDomANode parentToAppend = getParent(); + if (!parentToAppend.isPhraseNode()) parentToAppend = this; + Document ownerDoc = domNode.getOwnerDocument(); // Children container Node childenNode = (Node) XPathEngine.get().evaluate( - "./children", domNode, XPathConstants.NODE); + "./children", parentToAppend.domNode, XPathConstants.NODE); if (childenNode == null) { - childenNode = domNode.getOwnerDocument().createElement("children"); - domNode.appendChild(childenNode); + childenNode = ownerDoc.createElement("children"); + parentToAppend.domNode.appendChild(childenNode); } // Node itself - Element newTokenNode = domNode.getOwnerDocument().createElement("node"); + Element newTokenNode = ownerDoc.createElement("node"); childenNode.appendChild(newTokenNode); // id attribute @@ -769,9 +773,9 @@ public boolean splitMorphoEllipsis(String idPostfix) newTokenNode.appendChild(ord); // Role. - Node roleNode = domNode.getOwnerDocument().createElement("role"); + Node roleNode = ownerDoc.createElement("role"); newTokenNode.appendChild(roleNode); - roleNode.appendChild(domNode.getOwnerDocument().createTextNode(LvtbRoles.ELLIPSIS_TOKEN)); + roleNode.appendChild(ownerDoc.createTextNode(LvtbRoles.ELLIPSIS_TOKEN)); return true; } diff --git a/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/Sentence.java b/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/Sentence.java index 7f035be8..7cae72d7 100644 --- a/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/Sentence.java +++ b/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/Sentence.java @@ -194,8 +194,12 @@ protected HashMap> getGov2subj(PmlANode aNode, HashMap collectedPartSubjs = resultAccumulator.get(partId); diff --git a/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/NewSyntaxTransformator.java b/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/NewSyntaxTransformator.java index 2025967c..7827a307 100644 --- a/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/NewSyntaxTransformator.java +++ b/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/NewSyntaxTransformator.java @@ -1,8 +1,6 @@ package lv.ailab.lvtb.universalizer.transformator.syntax; -import lv.ailab.lvtb.universalizer.pml.LvtbRoles; import lv.ailab.lvtb.universalizer.pml.PmlANode; -import lv.ailab.lvtb.universalizer.pml.utils.PmlANodeListUtils; import lv.ailab.lvtb.universalizer.transformator.Sentence; import lv.ailab.lvtb.universalizer.transformator.TransformationParams; import lv.ailab.lvtb.universalizer.transformator.morpho.XPosLogic; @@ -139,9 +137,11 @@ else if (aNode.isPureReductionNode()) if (redXPostag.matches("v..([^p].*|p[du].*)") || ! params.UD_STANDARD_NULLNODES) { String newIdStub = newBasicRoot.getId(); - List tokenNodes = aNode.getChildren(LvtbRoles.ELLIPSIS_TOKEN); - if (tokenNodes != null && !tokenNodes.isEmpty()) - newIdStub = PmlANodeListUtils.getFirstByDescOrd(tokenNodes).getId(); + //List tokenNodes = aNode.getChildren(LvtbRoles.ELLIPSIS_TOKEN); + //if (tokenNodes != null && !tokenNodes.isEmpty()) + // newIdStub = PmlANodeListUtils.getFirstByDescOrd(tokenNodes).getId(); + PmlANode tokenNode = s.pmlTree.getDescendant(aNode.getId() + Sentence.ID_POSTFIX); + if (tokenNode != null) newIdStub = tokenNode.getId(); s.createNewEnhEllipsisNode(aNode, newIdStub, params.ADD_NODE_IDS); } diff --git a/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/PhrasePartDepLogic.java b/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/PhrasePartDepLogic.java index 05b4077f..a3d3f7f5 100644 --- a/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/PhrasePartDepLogic.java +++ b/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/PhrasePartDepLogic.java @@ -266,6 +266,12 @@ else if (nominal && ultimateAux) return Tuple.of(UDv2Relations.XCOMP, null); } + if (lvtbRole.equals(LvtbRoles.ELLIPSIS_TOKEN)) + { + String tag = aNode.getAnyTag(); + if (tag.matches("z.*")) return Tuple.of(UDv2Relations.PUNCT, null); + } + StandardLogger.l.doInsentenceWarning(String.format( "\"%s\" (%s) in \"%s\" has no UD label.", lvtbRole, nodeId, phraseType)); diff --git a/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/PhraseTransformator.java b/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/PhraseTransformator.java index 038da101..99bcbced 100644 --- a/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/PhraseTransformator.java +++ b/LVTB2UD/src/lv/ailab/lvtb/universalizer/transformator/syntax/PhraseTransformator.java @@ -675,36 +675,43 @@ protected PmlANode noModXPredToUD(PmlANode xNode) { // Get basElems and warn if there is none. List basElems = xNode.getChildren(LvtbRoles.BASELEM); + if (basElems != null && basElems.size() > 1) + throw new IllegalArgumentException(String.format( + "\"%s\" in sentence \"%s\" has multiple \"basElem\"", + xNode.getPhraseType(), s.id)); PmlANode basElem = PmlANodeListUtils.getLastByDeepOrd(basElems); if (basElem == null) throw new IllegalArgumentException(String.format( "\"%s\" in sentence \"%s\" has no \"basElem\"", xNode.getPhraseType(), s.id)); + PmlANode newRoot = basElem; + List auxes = xNode.getChildren(LvtbRoles.AUXVERB); PmlANode lastAux = PmlANodeListUtils.getLastByDeepOrd(auxes); - if (lastAux == null) + /*if (lastAux == null) throw new IllegalArgumentException(String.format( "\"%s\" in sentence \"%s\" has neither \"auxVerb\" nor \"mod\"", - xNode.getPhraseType(), s.id)); - if (auxes.size() > 1) for (int i = 0; i < auxes.size(); i++) + xNode.getPhraseType(), s.id));*/ + if (lastAux != null) { - String auxLemma = lastAux.getM().getLemma(); + if (auxes.size() > 1) for (int i = 0; i < auxes.size(); i++) + { + String auxLemma = lastAux.getM().getLemma(); + String auxRedLemma = lastAux.getReductionLemma(); + if (!MorphoTransformator.isTrueAux(auxLemma) && + !MorphoTransformator.isTrueAux(auxRedLemma)) + StandardLogger.l.doInsentenceWarning(String.format( + "xPred \"%s\" has multiple auxVerb one of which has lemma \"%s\".", + xNode.getParent().getId(), auxLemma)); + } + + PmlMNode lastAuxM = lastAux.getM(); + String auxLemma = lastAuxM == null ? null : lastAuxM.getLemma(); String auxRedLemma = lastAux.getReductionLemma(); - if (!MorphoTransformator.isTrueAux(auxLemma) && - !MorphoTransformator.isTrueAux(auxRedLemma)) - StandardLogger.l.doInsentenceWarning(String.format( - "xPred \"%s\" has multiple auxVerb one of which has lemma \"%s\".", - xNode.getParent().getId(), auxLemma)); + boolean ultimateAux = MorphoTransformator.isTrueAux(auxLemma) + || MorphoTransformator.isTrueAux(auxRedLemma); + if (!ultimateAux) newRoot = lastAux; } - - PmlMNode lastAuxM = lastAux.getM(); - String auxLemma = lastAuxM == null ? null : lastAuxM.getLemma(); - String auxRedLemma = lastAux.getReductionLemma(); - boolean ultimateAux = MorphoTransformator.isTrueAux(auxLemma) - || MorphoTransformator.isTrueAux(auxRedLemma); - - PmlANode newRoot = basElem; - if (!ultimateAux) newRoot = lastAux; List children = xNode.getChildren(); s.relinkAllConstituents(newRoot, children, xNode, params.PROPAGATE_CONJUNCTS, params.NO_EDEP_DUPLICATES);