nlptoolkit-annotatedtree 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -0
- package/dist/ChunkType.d.ts +5 -0
- package/dist/ChunkType.js +20 -0
- package/dist/ChunkType.js.map +1 -0
- package/dist/Layer/DependencyLayer.d.ts +4 -0
- package/dist/Layer/DependencyLayer.js +23 -0
- package/dist/Layer/DependencyLayer.js.map +1 -0
- package/dist/Layer/EnglishPropbankLayer.d.ts +6 -0
- package/dist/Layer/EnglishPropbankLayer.js +34 -0
- package/dist/Layer/EnglishPropbankLayer.js.map +1 -0
- package/dist/Layer/EnglishSemanticLayer.d.ts +4 -0
- package/dist/Layer/EnglishSemanticLayer.js +23 -0
- package/dist/Layer/EnglishSemanticLayer.js.map +1 -0
- package/dist/Layer/EnglishWordLayer.d.ts +4 -0
- package/dist/Layer/EnglishWordLayer.js +22 -0
- package/dist/Layer/EnglishWordLayer.js.map +1 -0
- package/dist/Layer/MetaMorphemeLayer.d.ts +8 -0
- package/dist/Layer/MetaMorphemeLayer.js +63 -0
- package/dist/Layer/MetaMorphemeLayer.js.map +1 -0
- package/dist/Layer/MetaMorphemesMovedLayer.d.ts +9 -0
- package/dist/Layer/MetaMorphemesMovedLayer.js +51 -0
- package/dist/Layer/MetaMorphemesMovedLayer.js.map +1 -0
- package/dist/Layer/MorphologicalAnalysisLayer.d.ts +11 -0
- package/dist/Layer/MorphologicalAnalysisLayer.js +110 -0
- package/dist/Layer/MorphologicalAnalysisLayer.js.map +1 -0
- package/dist/Layer/MultiWordLayer.d.ts +7 -0
- package/dist/Layer/MultiWordLayer.js +33 -0
- package/dist/Layer/MultiWordLayer.js.map +1 -0
- package/dist/Layer/MultiWordMultiItemLayer.d.ts +6 -0
- package/dist/Layer/MultiWordMultiItemLayer.js +18 -0
- package/dist/Layer/MultiWordMultiItemLayer.js.map +1 -0
- package/dist/Layer/NERLayer.d.ts +8 -0
- package/dist/Layer/NERLayer.js +32 -0
- package/dist/Layer/NERLayer.js.map +1 -0
- package/dist/Layer/PersianWordLayer.d.ts +4 -0
- package/dist/Layer/PersianWordLayer.js +22 -0
- package/dist/Layer/PersianWordLayer.js.map +1 -0
- package/dist/Layer/ShallowParseLayer.d.ts +5 -0
- package/dist/Layer/ShallowParseLayer.js +33 -0
- package/dist/Layer/ShallowParseLayer.js.map +1 -0
- package/dist/Layer/SingleWordLayer.d.ts +4 -0
- package/dist/Layer/SingleWordLayer.js +21 -0
- package/dist/Layer/SingleWordLayer.js.map +1 -0
- package/dist/Layer/SingleWordMultiItemLayer.d.ts +7 -0
- package/dist/Layer/SingleWordMultiItemLayer.js +33 -0
- package/dist/Layer/SingleWordMultiItemLayer.js.map +1 -0
- package/dist/Layer/SourceLanguageWordLayer.d.ts +4 -0
- package/dist/Layer/SourceLanguageWordLayer.js +22 -0
- package/dist/Layer/SourceLanguageWordLayer.js.map +1 -0
- package/dist/Layer/TargetLanguageWordLayer.d.ts +8 -0
- package/dist/Layer/TargetLanguageWordLayer.js +38 -0
- package/dist/Layer/TargetLanguageWordLayer.js.map +1 -0
- package/dist/Layer/TurkishPropbankLayer.d.ts +9 -0
- package/dist/Layer/TurkishPropbankLayer.js +35 -0
- package/dist/Layer/TurkishPropbankLayer.js.map +1 -0
- package/dist/Layer/TurkishSemanticLayer.d.ts +5 -0
- package/dist/Layer/TurkishSemanticLayer.js +33 -0
- package/dist/Layer/TurkishSemanticLayer.js.map +1 -0
- package/dist/Layer/TurkishWordLayer.d.ts +4 -0
- package/dist/Layer/TurkishWordLayer.js +22 -0
- package/dist/Layer/TurkishWordLayer.js.map +1 -0
- package/dist/Layer/WordLayer.d.ts +7 -0
- package/dist/Layer/WordLayer.js +26 -0
- package/dist/Layer/WordLayer.js.map +1 -0
- package/dist/LayerInfo.d.ts +45 -0
- package/dist/LayerInfo.js +474 -0
- package/dist/LayerInfo.js.map +1 -0
- package/dist/ParseNodeDrawable.d.ts +30 -0
- package/dist/ParseNodeDrawable.js +263 -0
- package/dist/ParseNodeDrawable.js.map +1 -0
- package/dist/ParseTreeDrawable.d.ts +31 -0
- package/dist/ParseTreeDrawable.js +200 -0
- package/dist/ParseTreeDrawable.js.map +1 -0
- package/dist/Processor/Condition/IsDoubleNode.d.ts +5 -0
- package/dist/Processor/Condition/IsDoubleNode.js +23 -0
- package/dist/Processor/Condition/IsDoubleNode.js.map +1 -0
- package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.d.ts +5 -0
- package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.js +23 -0
- package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.js.map +1 -0
- package/dist/Processor/Condition/IsEnglishLeafNode.d.ts +5 -0
- package/dist/Processor/Condition/IsEnglishLeafNode.js +25 -0
- package/dist/Processor/Condition/IsEnglishLeafNode.js.map +1 -0
- package/dist/Processor/Condition/IsLeafNode.d.ts +5 -0
- package/dist/Processor/Condition/IsLeafNode.js +20 -0
- package/dist/Processor/Condition/IsLeafNode.js.map +1 -0
- package/dist/Processor/Condition/IsNodeWithPredicate.d.ts +6 -0
- package/dist/Processor/Condition/IsNodeWithPredicate.js +29 -0
- package/dist/Processor/Condition/IsNodeWithPredicate.js.map +1 -0
- package/dist/Processor/Condition/IsNodeWithSymbol.d.ts +7 -0
- package/dist/Processor/Condition/IsNodeWithSymbol.js +28 -0
- package/dist/Processor/Condition/IsNodeWithSymbol.js.map +1 -0
- package/dist/Processor/Condition/IsNodeWithSynSetId.d.ts +7 -0
- package/dist/Processor/Condition/IsNodeWithSynSetId.js +34 -0
- package/dist/Processor/Condition/IsNodeWithSynSetId.js.map +1 -0
- package/dist/Processor/Condition/IsNoneNode.d.ts +8 -0
- package/dist/Processor/Condition/IsNoneNode.js +29 -0
- package/dist/Processor/Condition/IsNoneNode.js.map +1 -0
- package/dist/Processor/Condition/IsNullElement.d.ts +5 -0
- package/dist/Processor/Condition/IsNullElement.js +27 -0
- package/dist/Processor/Condition/IsNullElement.js.map +1 -0
- package/dist/Processor/Condition/IsNumber.d.ts +5 -0
- package/dist/Processor/Condition/IsNumber.js +27 -0
- package/dist/Processor/Condition/IsNumber.js.map +1 -0
- package/dist/Processor/Condition/IsPredicateVerbNode.d.ts +7 -0
- package/dist/Processor/Condition/IsPredicateVerbNode.js +28 -0
- package/dist/Processor/Condition/IsPredicateVerbNode.js.map +1 -0
- package/dist/Processor/Condition/IsProperNoun.d.ts +5 -0
- package/dist/Processor/Condition/IsProperNoun.js +25 -0
- package/dist/Processor/Condition/IsProperNoun.js.map +1 -0
- package/dist/Processor/Condition/IsPunctuationNode.d.ts +5 -0
- package/dist/Processor/Condition/IsPunctuationNode.js +27 -0
- package/dist/Processor/Condition/IsPunctuationNode.js.map +1 -0
- package/dist/Processor/Condition/IsTransferable.d.ts +8 -0
- package/dist/Processor/Condition/IsTransferable.js +33 -0
- package/dist/Processor/Condition/IsTransferable.js.map +1 -0
- package/dist/Processor/Condition/IsTurkishLeafNode.d.ts +5 -0
- package/dist/Processor/Condition/IsTurkishLeafNode.js +27 -0
- package/dist/Processor/Condition/IsTurkishLeafNode.js.map +1 -0
- package/dist/Processor/Condition/IsVPNode.d.ts +5 -0
- package/dist/Processor/Condition/IsVPNode.js +20 -0
- package/dist/Processor/Condition/IsVPNode.js.map +1 -0
- package/dist/Processor/Condition/IsVerbNode.d.ts +8 -0
- package/dist/Processor/Condition/IsVerbNode.js +36 -0
- package/dist/Processor/Condition/IsVerbNode.js.map +1 -0
- package/dist/Processor/Condition/NodeDrawableCondition.d.ts +4 -0
- package/dist/Processor/Condition/NodeDrawableCondition.js +13 -0
- package/dist/Processor/Condition/NodeDrawableCondition.js.map +1 -0
- package/dist/Processor/LayerExist/ContainsLayerInformation.d.ts +8 -0
- package/dist/Processor/LayerExist/ContainsLayerInformation.js +45 -0
- package/dist/Processor/LayerExist/ContainsLayerInformation.js.map +1 -0
- package/dist/Processor/LayerExist/LeafListCondition.d.ts +4 -0
- package/dist/Processor/LayerExist/LeafListCondition.js +13 -0
- package/dist/Processor/LayerExist/LeafListCondition.js.map +1 -0
- package/dist/Processor/LayerExist/NotContainsLayerInformation.d.ts +8 -0
- package/dist/Processor/LayerExist/NotContainsLayerInformation.js +44 -0
- package/dist/Processor/LayerExist/NotContainsLayerInformation.js.map +1 -0
- package/dist/Processor/LayerExist/SemiContainsLayerInformation.d.ts +8 -0
- package/dist/Processor/LayerExist/SemiContainsLayerInformation.js +53 -0
- package/dist/Processor/LayerExist/SemiContainsLayerInformation.js.map +1 -0
- package/dist/Processor/LeafConverter/LeafToEnglish.d.ts +4 -0
- package/dist/Processor/LeafConverter/LeafToEnglish.js +23 -0
- package/dist/Processor/LeafConverter/LeafToEnglish.js.map +1 -0
- package/dist/Processor/LeafConverter/LeafToLanguageConverter.d.ts +7 -0
- package/dist/Processor/LeafConverter/LeafToLanguageConverter.js +44 -0
- package/dist/Processor/LeafConverter/LeafToLanguageConverter.js.map +1 -0
- package/dist/Processor/LeafConverter/LeafToPersian.d.ts +4 -0
- package/dist/Processor/LeafConverter/LeafToPersian.js +23 -0
- package/dist/Processor/LeafConverter/LeafToPersian.js.map +1 -0
- package/dist/Processor/LeafConverter/LeafToRootFormConverter.d.ts +5 -0
- package/dist/Processor/LeafConverter/LeafToRootFormConverter.js +28 -0
- package/dist/Processor/LeafConverter/LeafToRootFormConverter.js.map +1 -0
- package/dist/Processor/LeafConverter/LeafToStringConverter.d.ts +4 -0
- package/dist/Processor/LeafConverter/LeafToStringConverter.js +13 -0
- package/dist/Processor/LeafConverter/LeafToStringConverter.js.map +1 -0
- package/dist/Processor/LeafConverter/LeafToTurkish.d.ts +4 -0
- package/dist/Processor/LeafConverter/LeafToTurkish.js +23 -0
- package/dist/Processor/LeafConverter/LeafToTurkish.js.map +1 -0
- package/dist/Processor/NodeDrawableCollector.d.ts +9 -0
- package/dist/Processor/NodeDrawableCollector.js +34 -0
- package/dist/Processor/NodeDrawableCollector.js.map +1 -0
- package/dist/Processor/NodeModification/ConvertToLayeredFormat.d.ts +5 -0
- package/dist/Processor/NodeModification/ConvertToLayeredFormat.js +26 -0
- package/dist/Processor/NodeModification/ConvertToLayeredFormat.js.map +1 -0
- package/dist/Processor/NodeModification/NodeModifier.d.ts +4 -0
- package/dist/Processor/NodeModification/NodeModifier.js +13 -0
- package/dist/Processor/NodeModification/NodeModifier.js.map +1 -0
- package/dist/Processor/TreeModifier.d.ts +6 -0
- package/dist/Processor/TreeModifier.js +26 -0
- package/dist/Processor/TreeModifier.js.map +1 -0
- package/dist/Processor/TreeToStringConverter.d.ts +9 -0
- package/dist/Processor/TreeToStringConverter.js +36 -0
- package/dist/Processor/TreeToStringConverter.js.map +1 -0
- package/dist/TreeBankDrawable.d.ts +11 -0
- package/dist/TreeBankDrawable.js +52 -0
- package/dist/TreeBankDrawable.js.map +1 -0
- package/index.js +58 -0
- package/package.json +37 -0
- package/source/ChunkType.ts +3 -0
- package/source/Layer/DependencyLayer.ts +10 -0
- package/source/Layer/EnglishPropbankLayer.ts +22 -0
- package/source/Layer/EnglishSemanticLayer.ts +10 -0
- package/source/Layer/EnglishWordLayer.ts +9 -0
- package/source/Layer/MetaMorphemeLayer.ts +53 -0
- package/source/Layer/MetaMorphemesMovedLayer.ts +43 -0
- package/source/Layer/MorphologicalAnalysisLayer.ts +100 -0
- package/source/Layer/MultiWordLayer.ts +20 -0
- package/source/Layer/MultiWordMultiItemLayer.ts +9 -0
- package/source/Layer/NERLayer.ts +23 -0
- package/source/Layer/PersianWordLayer.ts +9 -0
- package/source/Layer/ShallowParseLayer.ts +22 -0
- package/source/Layer/SingleWordLayer.ts +9 -0
- package/source/Layer/SingleWordMultiItemLayer.ts +19 -0
- package/source/Layer/SourceLanguageWordLayer.ts +9 -0
- package/source/Layer/TargetLanguageWordLayer.ts +29 -0
- package/source/Layer/TurkishPropbankLayer.ts +26 -0
- package/source/Layer/TurkishSemanticLayer.ts +22 -0
- package/source/Layer/TurkishWordLayer.ts +9 -0
- package/source/Layer/WordLayer.ts +17 -0
- package/source/LayerInfo.ts +481 -0
- package/source/ParseNodeDrawable.ts +257 -0
- package/source/ParseTreeDrawable.ts +205 -0
- package/source/Processor/Condition/IsDoubleNode.ts +13 -0
- package/source/Processor/Condition/IsDoubleNodeWithDifferentTags.ts +13 -0
- package/source/Processor/Condition/IsEnglishLeafNode.ts +14 -0
- package/source/Processor/Condition/IsLeafNode.ts +10 -0
- package/source/Processor/Condition/IsNodeWithPredicate.ts +19 -0
- package/source/Processor/Condition/IsNodeWithSymbol.ts +20 -0
- package/source/Processor/Condition/IsNodeWithSynSetId.ts +26 -0
- package/source/Processor/Condition/IsNoneNode.ts +22 -0
- package/source/Processor/Condition/IsNullElement.ts +16 -0
- package/source/Processor/Condition/IsNumber.ts +16 -0
- package/source/Processor/Condition/IsPredicateVerbNode.ts +19 -0
- package/source/Processor/Condition/IsProperNoun.ts +14 -0
- package/source/Processor/Condition/IsPunctuationNode.ts +16 -0
- package/source/Processor/Condition/IsTransferable.ts +26 -0
- package/source/Processor/Condition/IsTurkishLeafNode.ts +16 -0
- package/source/Processor/Condition/IsVPNode.ts +10 -0
- package/source/Processor/Condition/IsVerbNode.ts +29 -0
- package/source/Processor/Condition/NodeDrawableCondition.ts +6 -0
- package/source/Processor/LayerExist/ContainsLayerInformation.ts +38 -0
- package/source/Processor/LayerExist/LeafListCondition.ts +6 -0
- package/source/Processor/LayerExist/NotContainsLayerInformation.ts +37 -0
- package/source/Processor/LayerExist/SemiContainsLayerInformation.ts +44 -0
- package/source/Processor/LeafConverter/LeafToEnglish.ts +11 -0
- package/source/Processor/LeafConverter/LeafToLanguageConverter.ts +35 -0
- package/source/Processor/LeafConverter/LeafToPersian.ts +10 -0
- package/source/Processor/LeafConverter/LeafToRootFormConverter.ts +18 -0
- package/source/Processor/LeafConverter/LeafToStringConverter.ts +6 -0
- package/source/Processor/LeafConverter/LeafToTurkish.ts +10 -0
- package/source/Processor/NodeDrawableCollector.ts +28 -0
- package/source/Processor/NodeModification/ConvertToLayeredFormat.ts +16 -0
- package/source/Processor/NodeModification/NodeModifier.ts +6 -0
- package/source/Processor/TreeModifier.ts +20 -0
- package/source/Processor/TreeToStringConverter.ts +31 -0
- package/source/TreeBankDrawable.ts +47 -0
- package/source/tsconfig.json +13 -0
- package/tests/ParseTreeDrawableTest.ts +161 -0
- package/trees/0000.dev +1 -0
- package/trees/0001.dev +1 -0
- package/trees/0002.dev +1 -0
- package/trees/0003.dev +1 -0
- package/trees/0004.dev +1 -0
- package/trees/0005.dev +1 -0
- package/trees/0006.dev +1 -0
- package/trees/0007.dev +1 -0
- package/trees/0008.dev +1 -0
- package/trees/0009.dev +1 -0
- package/trees2/0000.dev +1 -0
- package/trees2/0001.dev +1 -0
- package/trees2/0002.dev +1 -0
- package/trees2/0003.dev +1 -0
- package/trees2/0004.dev +1 -0
- package/trees2/0005.dev +1 -0
- package/trees2/0006.dev +1 -0
- package/trees2/0007.dev +1 -0
- package/trees2/0008.dev +1 -0
- package/trees2/0009.dev +1 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {ParseNode} from "nlptoolkit-parsetree/dist/ParseNode";
|
|
2
|
+
import {LayerInfo} from "./LayerInfo";
|
|
3
|
+
import {Symbol} from "nlptoolkit-parsetree/dist/Symbol";
|
|
4
|
+
import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
5
|
+
import {Gazetteer} from "nlptoolkit-namedentityrecognition/dist/Gazetteer";
|
|
6
|
+
|
|
7
|
+
export class ParseNodeDrawable extends ParseNode{
|
|
8
|
+
|
|
9
|
+
protected layers: LayerInfo = null
|
|
10
|
+
protected depth: number
|
|
11
|
+
protected inOrderTraversalIndex: number
|
|
12
|
+
|
|
13
|
+
constructor(parentOrLeftOrSymbol?: any, lineOrRightOrData?: any, dataOrIsleaf?: any, depth?: number) {
|
|
14
|
+
super();
|
|
15
|
+
if (parentOrLeftOrSymbol == null || lineOrRightOrData != undefined){
|
|
16
|
+
let parent: ParseNodeDrawable = parentOrLeftOrSymbol
|
|
17
|
+
if (depth != undefined){
|
|
18
|
+
let line: string = lineOrRightOrData
|
|
19
|
+
let isLeaf: boolean = dataOrIsleaf
|
|
20
|
+
let parenthesisCount = 0;
|
|
21
|
+
let childLine = "";
|
|
22
|
+
this.depth = depth;
|
|
23
|
+
this.parent = parent;
|
|
24
|
+
if (isLeaf){
|
|
25
|
+
if (!line.includes("{")){
|
|
26
|
+
this.data = new Symbol(line);
|
|
27
|
+
} else {
|
|
28
|
+
this.layers = new LayerInfo(line);
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
let startPos = line.indexOf(" ");
|
|
32
|
+
this.data = new Symbol(line.substring(1, startPos));
|
|
33
|
+
if (line.indexOf(")") == line.lastIndexOf(")")){
|
|
34
|
+
this.children.push(new ParseNodeDrawable(this, line.substring(startPos + 1, line.indexOf(")")), true, depth + 1));
|
|
35
|
+
} else {
|
|
36
|
+
for (let i = startPos + 1; i < line.length; i++){
|
|
37
|
+
if (line[i] != ' ' || parenthesisCount > 0){
|
|
38
|
+
childLine = childLine + line[i];
|
|
39
|
+
}
|
|
40
|
+
if (line.charAt(i) == '('){
|
|
41
|
+
parenthesisCount++;
|
|
42
|
+
} else {
|
|
43
|
+
if (line.charAt(i) == ')'){
|
|
44
|
+
parenthesisCount--;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (parenthesisCount == 0 && childLine != ""){
|
|
48
|
+
this.children.push(new ParseNodeDrawable(this, childLine.trim(), false, depth + 1));
|
|
49
|
+
childLine = "";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
let child: ParseNodeDrawable = lineOrRightOrData
|
|
56
|
+
let symbol: string = dataOrIsleaf
|
|
57
|
+
this.depth = child.depth;
|
|
58
|
+
child.updateDepths(this.depth + 1);
|
|
59
|
+
this.parent = parent;
|
|
60
|
+
this.parent.setChild(parent.getChildIndex(child), this);
|
|
61
|
+
this.children.push(child);
|
|
62
|
+
child.parent = this;
|
|
63
|
+
this.data = new Symbol(symbol);
|
|
64
|
+
this.inOrderTraversalIndex = child.inOrderTraversalIndex;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getLayerInfo(): LayerInfo{
|
|
70
|
+
return this.layers
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getData(): Symbol{
|
|
74
|
+
if (this.layers == null){
|
|
75
|
+
return super.getData()
|
|
76
|
+
} else {
|
|
77
|
+
return new Symbol(this.getLayerData(ViewLayerType.ENGLISH_WORD));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
clearLayers(){
|
|
82
|
+
this.layers = new LayerInfo()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
clearLayer(layerType: ViewLayerType){
|
|
86
|
+
if (this.children.length == 0 && this.layerExists(layerType)){
|
|
87
|
+
this.layers.removeLayer(layerType)
|
|
88
|
+
}
|
|
89
|
+
for (let i = 0; i < this.numberOfChildren(); i++){
|
|
90
|
+
(<ParseNodeDrawable> this.children[i]).clearLayer(layerType);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
clearData(){
|
|
95
|
+
this.data = null
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
setDataAndClearLayers(data: Symbol){
|
|
99
|
+
super.setData(data)
|
|
100
|
+
this.layers = null
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setData(data: Symbol) {
|
|
104
|
+
if (this.layers == null){
|
|
105
|
+
super.setData(data);
|
|
106
|
+
} else {
|
|
107
|
+
this.layers.setLayerData(ViewLayerType.ENGLISH_WORD, data.getName());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
headWord(viewLayerType: ViewLayerType): string{
|
|
112
|
+
if (this.children.length > 0){
|
|
113
|
+
return (<ParseNodeDrawable> this.headChild()).headWord(viewLayerType);
|
|
114
|
+
} else {
|
|
115
|
+
return this.getLayerData(viewLayerType);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
getLayerData(viewLayer?: ViewLayerType): string{
|
|
120
|
+
if (viewLayer == undefined){
|
|
121
|
+
if (this.data != null){
|
|
122
|
+
return this.data.getName();
|
|
123
|
+
}
|
|
124
|
+
return this.layers.getLayerDescription();
|
|
125
|
+
} else {
|
|
126
|
+
if (viewLayer == ViewLayerType.WORD || this.layers == null){
|
|
127
|
+
return this.data.getName();
|
|
128
|
+
}
|
|
129
|
+
return this.layers.getLayerData(viewLayer);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getDepth(): number{
|
|
134
|
+
return this.depth
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
replaceChild(oldChild: ParseNodeDrawable, newChild: ParseNodeDrawable){
|
|
138
|
+
newChild.updateDepths(this.depth + 1);
|
|
139
|
+
newChild.parent = this;
|
|
140
|
+
this.children[this.children.indexOf(oldChild)] = newChild;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
updateDepths(depth: number){
|
|
144
|
+
this.depth = depth;
|
|
145
|
+
for (let aChildren of this.children){
|
|
146
|
+
let aChild = <ParseNodeDrawable> aChildren;
|
|
147
|
+
aChild.updateDepths(depth + 1);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
maxDepth(): number{
|
|
152
|
+
let depth = this.depth;
|
|
153
|
+
for (let aChildren of this.children) {
|
|
154
|
+
let aChild = <ParseNodeDrawable> aChildren;
|
|
155
|
+
if (aChild.maxDepth() > depth)
|
|
156
|
+
depth = aChild.maxDepth();
|
|
157
|
+
}
|
|
158
|
+
return depth;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
layerExists(viewLayerType: ViewLayerType): boolean{
|
|
162
|
+
if (this.children.length == 0){
|
|
163
|
+
if (this.getLayerData(viewLayerType) != null){
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
for (let aChild of this.children) {
|
|
168
|
+
if ((<ParseNodeDrawable>aChild).layerExists(viewLayerType)){
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
isDummyNode(): boolean {
|
|
177
|
+
let data = this.getLayerData(ViewLayerType.ENGLISH_WORD);
|
|
178
|
+
let parentData = (<ParseNodeDrawable> this.parent).getLayerData(ViewLayerType.ENGLISH_WORD);
|
|
179
|
+
let targetData = this.getLayerData(ViewLayerType.TURKISH_WORD);
|
|
180
|
+
if (data != null && parentData != null){
|
|
181
|
+
if (targetData != null && targetData.includes("*")){
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
return data.includes("*") || (data == "0" && parentData == "-NONE-");
|
|
185
|
+
} else {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
layerAll(viewLayerType: ViewLayerType): boolean{
|
|
191
|
+
if (this.children.length == 0){
|
|
192
|
+
if (this.getLayerData(viewLayerType) == null && !this.isDummyNode()){
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
for (let aChild of this.children) {
|
|
197
|
+
if (!(<ParseNodeDrawable> aChild).layerAll(viewLayerType)){
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
toTurkishSentence(): string{
|
|
206
|
+
if (this.children.length == 0){
|
|
207
|
+
if (this.getLayerData(ViewLayerType.TURKISH_WORD) != null && this.getLayerData(ViewLayerType.TURKISH_WORD) != "*NONE*"){
|
|
208
|
+
return " " + this.getLayerData(ViewLayerType.TURKISH_WORD)
|
|
209
|
+
.replace("-LRB-", "(")
|
|
210
|
+
.replace("-RRB-", ")")
|
|
211
|
+
.replace("-LSB-", "[")
|
|
212
|
+
.replace("-RSB-", "]")
|
|
213
|
+
.replace("-LCB-", "{")
|
|
214
|
+
.replace("-RCB-", "}")
|
|
215
|
+
.replace("-lrb-", "(")
|
|
216
|
+
.replace("-rrb-", ")")
|
|
217
|
+
.replace("-lsb-", "[")
|
|
218
|
+
.replace("-rsb-", "]")
|
|
219
|
+
.replace("-lcb-", "{")
|
|
220
|
+
.replace("-rcb-", "}");
|
|
221
|
+
} else {
|
|
222
|
+
return " ";
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
let st = "";
|
|
226
|
+
for (let aChild of this.children) {
|
|
227
|
+
st = st + (<ParseNodeDrawable> aChild).toTurkishSentence();
|
|
228
|
+
}
|
|
229
|
+
return st;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
checkGazetteer(gazetteer: Gazetteer, word: string){
|
|
234
|
+
if (gazetteer.contains(word) && this.getParent().getData().getName() == "NNP"){
|
|
235
|
+
this.getLayerInfo().setLayerData(ViewLayerType.NER, gazetteer.getName());
|
|
236
|
+
}
|
|
237
|
+
if (word.includes("'") && gazetteer.contains(word.substring(0, word.indexOf("'"))) && this.getParent().getData().getName() == "NNP"){
|
|
238
|
+
this.getLayerInfo().setLayerData(ViewLayerType.NER, gazetteer.getName());
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
toString(): string{
|
|
243
|
+
if (this.children.length < 2){
|
|
244
|
+
if (this.children.length < 1){
|
|
245
|
+
return this.getLayerData();
|
|
246
|
+
} else {
|
|
247
|
+
return "(" + this.data.getName() + " " + this.children[0].toString() + ")";
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
let st = "(" + this.data.getName();
|
|
251
|
+
for (let aChild of this.children) {
|
|
252
|
+
st = st + " " + aChild.toString();
|
|
253
|
+
}
|
|
254
|
+
return st + ") ";
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import {ParseTree} from "nlptoolkit-parsetree/dist/ParseTree";
|
|
2
|
+
import {FileDescription} from "nlptoolkit-corpus/dist/FileDescription";
|
|
3
|
+
import {ParseNode} from "nlptoolkit-parsetree/dist/ParseNode";
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import {ParseNodeDrawable} from "./ParseNodeDrawable";
|
|
6
|
+
import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
7
|
+
import {Symbol} from "nlptoolkit-parsetree/dist/Symbol";
|
|
8
|
+
import {NodeDrawableCollector} from "./Processor/NodeDrawableCollector";
|
|
9
|
+
import {IsTurkishLeafNode} from "./Processor/Condition/IsTurkishLeafNode";
|
|
10
|
+
import {AnnotatedSentence} from "nlptoolkit-annotatedsentence/dist/AnnotatedSentence";
|
|
11
|
+
import {IsEnglishLeafNode} from "./Processor/Condition/IsEnglishLeafNode";
|
|
12
|
+
import {AnnotatedWord} from "nlptoolkit-annotatedsentence/dist/AnnotatedWord";
|
|
13
|
+
|
|
14
|
+
export class ParseTreeDrawable extends ParseTree{
|
|
15
|
+
|
|
16
|
+
private fileDescription: FileDescription
|
|
17
|
+
private name: string
|
|
18
|
+
|
|
19
|
+
constructor(fileDescriptionOrPath?: any, fileDescriptionOrFileName?: any, index?: number) {
|
|
20
|
+
super();
|
|
21
|
+
if (fileDescriptionOrPath instanceof FileDescription){
|
|
22
|
+
this.fileDescription = fileDescriptionOrPath
|
|
23
|
+
this.readFromFile(fileDescriptionOrPath.getPath())
|
|
24
|
+
} else {
|
|
25
|
+
if (fileDescriptionOrFileName == undefined){
|
|
26
|
+
let path: string = fileDescriptionOrPath
|
|
27
|
+
this.readFromFile(path)
|
|
28
|
+
} else {
|
|
29
|
+
if (fileDescriptionOrFileName instanceof FileDescription){
|
|
30
|
+
let path: string = fileDescriptionOrPath
|
|
31
|
+
let fileDescription: FileDescription = fileDescriptionOrFileName
|
|
32
|
+
this.fileDescription = new FileDescription(path, fileDescription.getExtension(), fileDescription.getIndex())
|
|
33
|
+
this.readFromFile(this.fileDescription.getPath())
|
|
34
|
+
} else {
|
|
35
|
+
if (index == undefined){
|
|
36
|
+
let path: string = fileDescriptionOrPath
|
|
37
|
+
let rawFileName: string = fileDescriptionOrFileName
|
|
38
|
+
this.fileDescription = new FileDescription(path, rawFileName)
|
|
39
|
+
this.readFromFile(this.fileDescription.getPath())
|
|
40
|
+
} else {
|
|
41
|
+
let path: string = fileDescriptionOrPath
|
|
42
|
+
let extension: string = fileDescriptionOrFileName
|
|
43
|
+
this.fileDescription = new FileDescription(path, extension, index)
|
|
44
|
+
this.readFromFile(this.fileDescription.getPath())
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setFileDescription(fileDescription: FileDescription){
|
|
52
|
+
this.fileDescription = fileDescription
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getFileDescription(){
|
|
56
|
+
return this.fileDescription
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
reload(){
|
|
60
|
+
this.readFromFile(this.fileDescription.getPath());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setRoot(newRootNode: ParseNode){
|
|
64
|
+
this.root = newRootNode
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
readFromFile(currentPath: string) {
|
|
68
|
+
let data = fs.readFileSync(currentPath, 'utf8')
|
|
69
|
+
let line = data.split("\n")[0]
|
|
70
|
+
if (line.includes("(") && line.includes(")")) {
|
|
71
|
+
line = line.substring(line.indexOf("(") + 1, line.lastIndexOf(")")).trim();
|
|
72
|
+
this.root = new ParseNodeDrawable(null, line, false, 0);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setName(name: string){
|
|
77
|
+
this.name = name
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
nextTree(count: number){
|
|
81
|
+
if (this.fileDescription.nextFileExists(count)){
|
|
82
|
+
this.fileDescription.addToIndex(count);
|
|
83
|
+
this.reload();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
previousTree(count: number){
|
|
88
|
+
if (this.fileDescription.previousFileExists(count)){
|
|
89
|
+
this.fileDescription.addToIndex(-count);
|
|
90
|
+
this.reload();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
maxDepth(): number{
|
|
95
|
+
return (<ParseNodeDrawable> this.root).maxDepth()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
moveLeft(node: ParseNode){
|
|
99
|
+
if (this.root != node){
|
|
100
|
+
this.root.moveLeft(node);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
moveRight(node: ParseNode){
|
|
105
|
+
if (this.root != node){
|
|
106
|
+
this.root.moveRight(node);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
divideIntoWords(parseNode: ParseNodeDrawable) {
|
|
111
|
+
let layers = parseNode.getLayerInfo().divideIntoWords();
|
|
112
|
+
parseNode.getParent().removeChild(parseNode);
|
|
113
|
+
for (let layerInfo of layers) {
|
|
114
|
+
let symbol
|
|
115
|
+
if (layerInfo.layerExists(ViewLayerType.INFLECTIONAL_GROUP)) {
|
|
116
|
+
symbol = new Symbol(layerInfo.getMorphologicalParseAt(0).getTreePos());
|
|
117
|
+
} else {
|
|
118
|
+
symbol = new Symbol("-XXX-");
|
|
119
|
+
}
|
|
120
|
+
let child = new ParseNodeDrawable(symbol);
|
|
121
|
+
parseNode.getParent().addChild(child);
|
|
122
|
+
let grandChild = new ParseNodeDrawable(child, layerInfo.getLayerDescription(), true, parseNode.getDepth() + 1);
|
|
123
|
+
child.addChild(grandChild);
|
|
124
|
+
(<ParseNodeDrawable>this.root).updateDepths(0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
moveNode(fromNode: ParseNode, toNode: ParseNode, childIndex?: number){
|
|
129
|
+
if (this.root != fromNode){
|
|
130
|
+
let parent = fromNode.getParent();
|
|
131
|
+
parent.removeChild(fromNode);
|
|
132
|
+
toNode.addChild(fromNode, childIndex);
|
|
133
|
+
(<ParseNodeDrawable> this.root).updateDepths(0);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
combineWords(parent: ParseNodeDrawable, child: ParseNodeDrawable){
|
|
138
|
+
while (parent.numberOfChildren() > 0){
|
|
139
|
+
parent.removeChild(parent.firstChild());
|
|
140
|
+
}
|
|
141
|
+
parent.addChild(child);
|
|
142
|
+
(<ParseNodeDrawable> this.root).updateDepths(0);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
layerExists(viewLayerType: ViewLayerType): boolean{
|
|
146
|
+
return (<ParseNodeDrawable>(this.root)).layerExists(viewLayerType);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
layerAll(viewLayerType: ViewLayerType): boolean{
|
|
150
|
+
return (<ParseNodeDrawable>(this.root)).layerAll(viewLayerType);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
clearLayer(layerType: ViewLayerType){
|
|
154
|
+
if (this.root != null){
|
|
155
|
+
(<ParseNodeDrawable>this.root).clearLayer(layerType);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
nextLeafNode(parseNode: ParseNodeDrawable): ParseNodeDrawable {
|
|
160
|
+
let nodeDrawableCollector = new NodeDrawableCollector(<ParseNodeDrawable>this.root, new IsTurkishLeafNode());
|
|
161
|
+
let leafList = nodeDrawableCollector.collect();
|
|
162
|
+
for (let i = 0; i < leafList.length - 1; i++){
|
|
163
|
+
if (leafList[i] == parseNode){
|
|
164
|
+
return leafList[i + 1];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
previousLeafNode(parseNode: ParseNodeDrawable): ParseNodeDrawable {
|
|
171
|
+
let nodeDrawableCollector = new NodeDrawableCollector(<ParseNodeDrawable>this.root, new IsTurkishLeafNode());
|
|
172
|
+
let leafList = nodeDrawableCollector.collect();
|
|
173
|
+
for (let i = 1; i < leafList.length; i++){
|
|
174
|
+
if (leafList[i] == parseNode){
|
|
175
|
+
return leafList[i - 1];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
generateAnnotatedSentence(language?: string): AnnotatedSentence{
|
|
182
|
+
if (language == undefined){
|
|
183
|
+
let sentence = new AnnotatedSentence();
|
|
184
|
+
let nodeDrawableCollector = new NodeDrawableCollector(<ParseNodeDrawable>this.root, new IsTurkishLeafNode());
|
|
185
|
+
let leafList = nodeDrawableCollector.collect();
|
|
186
|
+
for (let parseNode of leafList){
|
|
187
|
+
let layers = parseNode.getLayerInfo();
|
|
188
|
+
for (let i = 0; i < layers.getNumberOfWords(); i++){
|
|
189
|
+
sentence.addWord(layers.toAnnotatedWord(i));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return sentence;
|
|
193
|
+
} else {
|
|
194
|
+
let sentence = new AnnotatedSentence();
|
|
195
|
+
let nodeDrawableCollector = new NodeDrawableCollector(<ParseNodeDrawable>this.root, new IsEnglishLeafNode());
|
|
196
|
+
let leafList = nodeDrawableCollector.collect();
|
|
197
|
+
for (let parseNode of leafList){
|
|
198
|
+
let newWord = new AnnotatedWord("{" + language + "=" + parseNode.getData().getName() + "}{posTag="
|
|
199
|
+
+ parseNode.getParent().getData().getName() + "}");
|
|
200
|
+
sentence.addWord(newWord);
|
|
201
|
+
}
|
|
202
|
+
return sentence;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {NodeDrawableCondition} from "./NodeDrawableCondition";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
|
|
4
|
+
export class IsDoubleNode implements NodeDrawableCondition{
|
|
5
|
+
|
|
6
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
7
|
+
return parseNode.numberOfChildren() == 1
|
|
8
|
+
&& parseNode.getChild(0).numberOfChildren() >= 1
|
|
9
|
+
&& !parseNode.getChild(0).isLeaf()
|
|
10
|
+
&& parseNode.getData() == parseNode.getChild(0).getData();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {NodeDrawableCondition} from "./NodeDrawableCondition";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
|
|
4
|
+
export class IsDoubleNodeWithDifferentTags implements NodeDrawableCondition{
|
|
5
|
+
|
|
6
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
7
|
+
return parseNode.numberOfChildren() == 1
|
|
8
|
+
&& parseNode.getChild(0).numberOfChildren() >= 1
|
|
9
|
+
&& !parseNode.getChild(0).isLeaf()
|
|
10
|
+
&& parseNode.getData() != parseNode.getChild(0).getData();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {IsLeafNode} from "./IsLeafNode";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
import {IsNullElement} from "./IsNullElement";
|
|
4
|
+
|
|
5
|
+
export class IsEnglishLeafNode extends IsLeafNode{
|
|
6
|
+
|
|
7
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
8
|
+
if (super.satisfies(parseNode)) {
|
|
9
|
+
return !new IsNullElement().satisfies(parseNode);
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {NodeDrawableCondition} from "./NodeDrawableCondition";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
|
|
4
|
+
export class IsLeafNode implements NodeDrawableCondition{
|
|
5
|
+
|
|
6
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
7
|
+
return parseNode.numberOfChildren() == 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {IsNodeWithSynSetId} from "./IsNodeWithSynSetId";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
4
|
+
|
|
5
|
+
export class IsNodeWithPredicate extends IsNodeWithSynSetId{
|
|
6
|
+
|
|
7
|
+
constructor(id: string) {
|
|
8
|
+
super(id);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
12
|
+
let layerInfo = parseNode.getLayerInfo();
|
|
13
|
+
return super.satisfies(parseNode)
|
|
14
|
+
&& layerInfo != null
|
|
15
|
+
&& layerInfo.getLayerData(ViewLayerType.PROPBANK) != null
|
|
16
|
+
&& layerInfo.getLayerData(ViewLayerType.PROPBANK) == "PREDICATE";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {NodeDrawableCondition} from "./NodeDrawableCondition";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
|
|
4
|
+
export class IsNodeWithSymbol implements NodeDrawableCondition{
|
|
5
|
+
|
|
6
|
+
private symbol: string
|
|
7
|
+
|
|
8
|
+
constructor(symbol: string) {
|
|
9
|
+
this.symbol = symbol
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
13
|
+
if (parseNode.numberOfChildren() > 0){
|
|
14
|
+
return parseNode.getData().toString() == this.symbol;
|
|
15
|
+
} else {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {IsLeafNode} from "./IsLeafNode";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
|
|
4
|
+
export class IsNodeWithSynSetId extends IsLeafNode{
|
|
5
|
+
|
|
6
|
+
private id: string
|
|
7
|
+
|
|
8
|
+
constructor(id: string) {
|
|
9
|
+
super();
|
|
10
|
+
this.id = id
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
14
|
+
if (super.satisfies(parseNode)){
|
|
15
|
+
let layerInfo = parseNode.getLayerInfo();
|
|
16
|
+
for (let i = 0; i < layerInfo.getNumberOfMeanings(); i++) {
|
|
17
|
+
let synSetId = layerInfo.getSemanticAt(i);
|
|
18
|
+
if (synSetId == this.id){
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {IsLeafNode} from "./IsLeafNode";
|
|
2
|
+
import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
3
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
4
|
+
|
|
5
|
+
export class IsNoneNode extends IsLeafNode{
|
|
6
|
+
|
|
7
|
+
private secondLanguage: ViewLayerType
|
|
8
|
+
|
|
9
|
+
constructor(secondLanguage: ViewLayerType) {
|
|
10
|
+
super();
|
|
11
|
+
this.secondLanguage = secondLanguage
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
15
|
+
if (super.satisfies(parseNode)){
|
|
16
|
+
let data = parseNode.getLayerData(this.secondLanguage);
|
|
17
|
+
return data != null && data == "*NONE*";
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {IsLeafNode} from "./IsLeafNode";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
4
|
+
|
|
5
|
+
export class IsNullElement extends IsLeafNode{
|
|
6
|
+
|
|
7
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
8
|
+
if (super.satisfies(parseNode)){
|
|
9
|
+
let data = parseNode.getLayerData(ViewLayerType.ENGLISH_WORD);
|
|
10
|
+
let parentData = parseNode.getParent().getData().getName();
|
|
11
|
+
return data.includes("*") || (data == "0" && parentData == "-NONE-");
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {IsLeafNode} from "./IsLeafNode";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
4
|
+
|
|
5
|
+
export class IsNumber extends IsLeafNode{
|
|
6
|
+
|
|
7
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
8
|
+
if (super.satisfies(parseNode)){
|
|
9
|
+
let data = parseNode.getLayerData(ViewLayerType.ENGLISH_WORD);
|
|
10
|
+
let parentData = parseNode.getParent().getData().getName();
|
|
11
|
+
return parentData == "CD" && !Number.isNaN(data);
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {IsVerbNode} from "./IsVerbNode";
|
|
2
|
+
import {WordNet} from "nlptoolkit-wordnet/dist/WordNet";
|
|
3
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
4
|
+
|
|
5
|
+
export class IsPredicateVerbNode extends IsVerbNode{
|
|
6
|
+
|
|
7
|
+
constructor(wordNet: WordNet) {
|
|
8
|
+
super(wordNet);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
12
|
+
let layerInfo = parseNode.getLayerInfo();
|
|
13
|
+
return super.satisfies(parseNode)
|
|
14
|
+
&& layerInfo != null
|
|
15
|
+
&& layerInfo.getArgument() != null
|
|
16
|
+
&& layerInfo.getArgument().getArgumentType() == "PREDICATE";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {IsLeafNode} from "./IsLeafNode";
|
|
2
|
+
import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
3
|
+
|
|
4
|
+
export class IsProperNoun extends IsLeafNode{
|
|
5
|
+
|
|
6
|
+
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
7
|
+
if (super.satisfies(parseNode)){
|
|
8
|
+
let parentData = parseNode.getParent().getData().getName();
|
|
9
|
+
return parentData == "NNP" || parentData == "NNPS";
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|