nlptoolkit-annotatedtree 1.0.2 → 1.0.4
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 +6 -1
- package/dist/Layer/DependencyLayer.d.ts +4 -0
- package/dist/Layer/DependencyLayer.js +4 -0
- package/dist/Layer/DependencyLayer.js.map +1 -1
- package/dist/Layer/EnglishPropbankLayer.d.ts +9 -0
- package/dist/Layer/EnglishPropbankLayer.js +9 -0
- package/dist/Layer/EnglishPropbankLayer.js.map +1 -1
- package/dist/Layer/EnglishSemanticLayer.d.ts +5 -0
- package/dist/Layer/EnglishSemanticLayer.js +5 -0
- package/dist/Layer/EnglishSemanticLayer.js.map +1 -1
- package/dist/Layer/EnglishWordLayer.d.ts +4 -0
- package/dist/Layer/EnglishWordLayer.js +4 -0
- package/dist/Layer/EnglishWordLayer.js.map +1 -1
- package/dist/Layer/MetaMorphemeLayer.d.ts +19 -0
- package/dist/Layer/MetaMorphemeLayer.js +19 -0
- package/dist/Layer/MetaMorphemeLayer.js.map +1 -1
- package/dist/Layer/MetaMorphemesMovedLayer.d.ts +20 -0
- package/dist/Layer/MetaMorphemesMovedLayer.js +20 -0
- package/dist/Layer/MetaMorphemesMovedLayer.js.map +1 -1
- package/dist/Layer/MorphologicalAnalysisLayer.d.ts +32 -0
- package/dist/Layer/MorphologicalAnalysisLayer.js +32 -0
- package/dist/Layer/MorphologicalAnalysisLayer.js.map +1 -1
- package/dist/Layer/MultiWordLayer.d.ts +9 -0
- package/dist/Layer/MultiWordLayer.js +9 -0
- package/dist/Layer/MultiWordLayer.js.map +1 -1
- package/dist/Layer/NERLayer.d.ts +14 -0
- package/dist/Layer/NERLayer.js +14 -0
- package/dist/Layer/NERLayer.js.map +1 -1
- package/dist/Layer/PersianWordLayer.d.ts +4 -0
- package/dist/Layer/PersianWordLayer.js +4 -0
- package/dist/Layer/PersianWordLayer.js.map +1 -1
- package/dist/Layer/ShallowParseLayer.d.ts +11 -0
- package/dist/Layer/ShallowParseLayer.js +11 -0
- package/dist/Layer/ShallowParseLayer.js.map +1 -1
- package/dist/Layer/SingleWordLayer.d.ts +4 -0
- package/dist/Layer/SingleWordLayer.js +4 -0
- package/dist/Layer/SingleWordLayer.js.map +1 -1
- package/dist/Layer/SourceLanguageWordLayer.d.ts +4 -0
- package/dist/Layer/SourceLanguageWordLayer.js +4 -0
- package/dist/Layer/SourceLanguageWordLayer.js.map +1 -1
- package/dist/Layer/TargetLanguageWordLayer.d.ts +10 -1
- package/dist/Layer/TargetLanguageWordLayer.js +9 -0
- package/dist/Layer/TargetLanguageWordLayer.js.map +1 -1
- package/dist/Layer/TurkishPropbankLayer.d.ts +18 -0
- package/dist/Layer/TurkishPropbankLayer.js +18 -0
- package/dist/Layer/TurkishPropbankLayer.js.map +1 -1
- package/dist/Layer/TurkishSemanticLayer.d.ts +11 -0
- package/dist/Layer/TurkishSemanticLayer.js +11 -0
- package/dist/Layer/TurkishSemanticLayer.js.map +1 -1
- package/dist/Layer/TurkishWordLayer.d.ts +4 -0
- package/dist/Layer/TurkishWordLayer.js +4 -0
- package/dist/Layer/TurkishWordLayer.js.map +1 -1
- package/dist/Layer/WordLayer.d.ts +12 -0
- package/dist/Layer/WordLayer.js +12 -0
- package/dist/Layer/WordLayer.js.map +1 -1
- package/dist/LayerInfo.d.ts +188 -0
- package/dist/LayerInfo.js +229 -63
- package/dist/LayerInfo.js.map +1 -1
- package/dist/ParseNodeDrawable.d.ts +102 -0
- package/dist/ParseNodeDrawable.js +102 -0
- package/dist/ParseNodeDrawable.js.map +1 -1
- package/dist/ParseTreeDrawable.d.ts +134 -0
- package/dist/ParseTreeDrawable.js +153 -16
- package/dist/ParseTreeDrawable.js.map +1 -1
- package/dist/Processor/Condition/IsDoubleNode.d.ts +6 -0
- package/dist/Processor/Condition/IsDoubleNode.js +6 -0
- package/dist/Processor/Condition/IsDoubleNode.js.map +1 -1
- package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.d.ts +6 -0
- package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.js +6 -0
- package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.js.map +1 -1
- package/dist/Processor/Condition/IsEnglishLeafNode.d.ts +5 -0
- package/dist/Processor/Condition/IsEnglishLeafNode.js +5 -0
- package/dist/Processor/Condition/IsEnglishLeafNode.js.map +1 -1
- package/dist/Processor/Condition/IsLeafNode.d.ts +5 -0
- package/dist/Processor/Condition/IsLeafNode.js +5 -0
- package/dist/Processor/Condition/IsLeafNode.js.map +1 -1
- package/dist/Processor/Condition/IsNodeWithPredicate.d.ts +11 -0
- package/dist/Processor/Condition/IsNodeWithPredicate.js +11 -0
- package/dist/Processor/Condition/IsNodeWithPredicate.js.map +1 -1
- package/dist/Processor/Condition/IsNodeWithSymbol.d.ts +9 -0
- package/dist/Processor/Condition/IsNodeWithSymbol.js +9 -0
- package/dist/Processor/Condition/IsNodeWithSymbol.js.map +1 -1
- package/dist/Processor/Condition/IsNodeWithSynSetId.d.ts +9 -0
- package/dist/Processor/Condition/IsNodeWithSynSetId.js +9 -0
- package/dist/Processor/Condition/IsNodeWithSynSetId.js.map +1 -1
- package/dist/Processor/Condition/IsNoneNode.d.ts +5 -0
- package/dist/Processor/Condition/IsNoneNode.js +5 -0
- package/dist/Processor/Condition/IsNoneNode.js.map +1 -1
- package/dist/Processor/Condition/IsNullElement.d.ts +6 -0
- package/dist/Processor/Condition/IsNullElement.js +6 -0
- package/dist/Processor/Condition/IsNullElement.js.map +1 -1
- package/dist/Processor/Condition/IsNumber.d.ts +6 -0
- package/dist/Processor/Condition/IsNumber.js +6 -0
- package/dist/Processor/Condition/IsNumber.js.map +1 -1
- package/dist/Processor/Condition/IsPredicateVerbNode.d.ts +11 -0
- package/dist/Processor/Condition/IsPredicateVerbNode.js +11 -0
- package/dist/Processor/Condition/IsPredicateVerbNode.js.map +1 -1
- package/dist/Processor/Condition/IsProperNoun.d.ts +5 -0
- package/dist/Processor/Condition/IsProperNoun.js +5 -0
- package/dist/Processor/Condition/IsProperNoun.js.map +1 -1
- package/dist/Processor/Condition/IsPunctuationNode.d.ts +5 -0
- package/dist/Processor/Condition/IsPunctuationNode.js +5 -0
- package/dist/Processor/Condition/IsPunctuationNode.js.map +1 -1
- package/dist/Processor/Condition/IsTransferable.d.ts +5 -0
- package/dist/Processor/Condition/IsTransferable.js +5 -0
- package/dist/Processor/Condition/IsTransferable.js.map +1 -1
- package/dist/Processor/Condition/IsTurkishLeafNode.d.ts +5 -0
- package/dist/Processor/Condition/IsTurkishLeafNode.js +5 -0
- package/dist/Processor/Condition/IsTurkishLeafNode.js.map +1 -1
- package/dist/Processor/Condition/IsVPNode.d.ts +5 -0
- package/dist/Processor/Condition/IsVPNode.js +5 -0
- package/dist/Processor/Condition/IsVPNode.js.map +1 -1
- package/dist/Processor/Condition/IsVerbNode.d.ts +10 -0
- package/dist/Processor/Condition/IsVerbNode.js +10 -0
- package/dist/Processor/Condition/IsVerbNode.js.map +1 -1
- package/dist/Processor/LayerExist/ContainsLayerInformation.d.ts +9 -0
- package/dist/Processor/LayerExist/ContainsLayerInformation.js +9 -0
- package/dist/Processor/LayerExist/ContainsLayerInformation.js.map +1 -1
- package/dist/Processor/LayerExist/NotContainsLayerInformation.d.ts +9 -0
- package/dist/Processor/LayerExist/NotContainsLayerInformation.js +9 -0
- package/dist/Processor/LayerExist/NotContainsLayerInformation.js.map +1 -1
- package/dist/Processor/LayerExist/SemiContainsLayerInformation.d.ts +10 -0
- package/dist/Processor/LayerExist/SemiContainsLayerInformation.js +10 -0
- package/dist/Processor/LayerExist/SemiContainsLayerInformation.js.map +1 -1
- package/dist/Processor/LeafConverter/LeafToEnglish.d.ts +3 -0
- package/dist/Processor/LeafConverter/LeafToEnglish.js +3 -0
- package/dist/Processor/LeafConverter/LeafToEnglish.js.map +1 -1
- package/dist/Processor/LeafConverter/LeafToLanguageConverter.d.ts +7 -0
- package/dist/Processor/LeafConverter/LeafToLanguageConverter.js +7 -0
- package/dist/Processor/LeafConverter/LeafToLanguageConverter.js.map +1 -1
- package/dist/Processor/LeafConverter/LeafToPersian.d.ts +3 -0
- package/dist/Processor/LeafConverter/LeafToPersian.js +3 -0
- package/dist/Processor/LeafConverter/LeafToPersian.js.map +1 -1
- package/dist/Processor/LeafConverter/LeafToRootFormConverter.d.ts +7 -0
- package/dist/Processor/LeafConverter/LeafToRootFormConverter.js +7 -0
- package/dist/Processor/LeafConverter/LeafToRootFormConverter.js.map +1 -1
- package/dist/Processor/LeafConverter/LeafToTurkish.d.ts +3 -0
- package/dist/Processor/LeafConverter/LeafToTurkish.js +3 -0
- package/dist/Processor/LeafConverter/LeafToTurkish.js.map +1 -1
- package/dist/Processor/NodeDrawableCollector.d.ts +16 -0
- package/dist/Processor/NodeDrawableCollector.js +16 -0
- package/dist/Processor/NodeDrawableCollector.js.map +1 -1
- package/dist/Processor/TreeToStringConverter.d.ts +15 -0
- package/dist/Processor/TreeToStringConverter.js +15 -0
- package/dist/Processor/TreeToStringConverter.js.map +1 -1
- package/dist/TreeBankDrawable.d.ts +20 -0
- package/dist/TreeBankDrawable.js +20 -0
- package/dist/TreeBankDrawable.js.map +1 -1
- package/package.json +14 -12
- package/source/Layer/DependencyLayer.ts +4 -0
- package/source/Layer/EnglishPropbankLayer.ts +9 -0
- package/source/Layer/EnglishSemanticLayer.ts +5 -0
- package/source/Layer/EnglishWordLayer.ts +4 -0
- package/source/Layer/MetaMorphemeLayer.ts +19 -0
- package/source/Layer/MetaMorphemesMovedLayer.ts +20 -0
- package/source/Layer/MorphologicalAnalysisLayer.ts +32 -0
- package/source/Layer/MultiWordLayer.ts +9 -0
- package/source/Layer/NERLayer.ts +14 -0
- package/source/Layer/PersianWordLayer.ts +4 -0
- package/source/Layer/ShallowParseLayer.ts +11 -0
- package/source/Layer/SingleWordLayer.ts +4 -0
- package/source/Layer/SourceLanguageWordLayer.ts +4 -0
- package/source/Layer/TargetLanguageWordLayer.ts +10 -1
- package/source/Layer/TurkishPropbankLayer.ts +18 -0
- package/source/Layer/TurkishSemanticLayer.ts +11 -0
- package/source/Layer/TurkishWordLayer.ts +4 -0
- package/source/Layer/WordLayer.ts +12 -0
- package/source/LayerInfo.ts +333 -155
- package/source/ParseNodeDrawable.ts +102 -0
- package/source/ParseTreeDrawable.ts +158 -16
- package/source/Processor/Condition/IsDoubleNode.ts +6 -0
- package/source/Processor/Condition/IsDoubleNodeWithDifferentTags.ts +6 -0
- package/source/Processor/Condition/IsEnglishLeafNode.ts +5 -0
- package/source/Processor/Condition/IsLeafNode.ts +5 -0
- package/source/Processor/Condition/IsNodeWithPredicate.ts +11 -0
- package/source/Processor/Condition/IsNodeWithSymbol.ts +9 -0
- package/source/Processor/Condition/IsNodeWithSynSetId.ts +9 -0
- package/source/Processor/Condition/IsNoneNode.ts +5 -0
- package/source/Processor/Condition/IsNullElement.ts +6 -0
- package/source/Processor/Condition/IsNumber.ts +6 -0
- package/source/Processor/Condition/IsPredicateVerbNode.ts +11 -0
- package/source/Processor/Condition/IsProperNoun.ts +5 -0
- package/source/Processor/Condition/IsPunctuationNode.ts +5 -0
- package/source/Processor/Condition/IsTransferable.ts +5 -0
- package/source/Processor/Condition/IsTurkishLeafNode.ts +5 -0
- package/source/Processor/Condition/IsVPNode.ts +5 -0
- package/source/Processor/Condition/IsVerbNode.ts +10 -0
- package/source/Processor/LayerExist/ContainsLayerInformation.ts +9 -0
- package/source/Processor/LayerExist/NotContainsLayerInformation.ts +9 -0
- package/source/Processor/LayerExist/SemiContainsLayerInformation.ts +10 -0
- package/source/Processor/LeafConverter/LeafToEnglish.ts +3 -0
- package/source/Processor/LeafConverter/LeafToLanguageConverter.ts +7 -0
- package/source/Processor/LeafConverter/LeafToPersian.ts +3 -0
- package/source/Processor/LeafConverter/LeafToRootFormConverter.ts +7 -0
- package/source/Processor/LeafConverter/LeafToTurkish.ts +3 -0
- package/source/Processor/NodeDrawableCollector.ts +16 -0
- package/source/Processor/TreeToStringConverter.ts +15 -0
- package/source/TreeBankDrawable.ts +20 -0
|
@@ -4,6 +4,12 @@ import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
|
4
4
|
|
|
5
5
|
export class IsNumber extends IsLeafNode{
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the node is a leaf node and contains numerals as the data and its parent has the tag CD.
|
|
9
|
+
* @param parseNode Parse node to check.
|
|
10
|
+
* @return True if the node is a leaf node and contains numerals as the data and its parent has the tag CD, false
|
|
11
|
+
* otherwise.
|
|
12
|
+
*/
|
|
7
13
|
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
8
14
|
if (super.satisfies(parseNode)){
|
|
9
15
|
let data = parseNode.getLayerData(ViewLayerType.ENGLISH_WORD);
|
|
@@ -4,10 +4,21 @@ import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
|
4
4
|
|
|
5
5
|
export class IsPredicateVerbNode extends IsVerbNode{
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Stores the wordnet for checking the pos tag of the synset.
|
|
9
|
+
* @param wordNet Wordnet used for checking the pos tag of the synset.
|
|
10
|
+
*/
|
|
7
11
|
constructor(wordNet: WordNet) {
|
|
8
12
|
super(wordNet);
|
|
9
13
|
}
|
|
10
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Checks if the node is a leaf node and at least one of the semantic ids of the parse node belong to a verb synset,
|
|
17
|
+
* and the semantic role of the node is PREDICATE.
|
|
18
|
+
* @param parseNode Parse node to check.
|
|
19
|
+
* @return True if the node is a leaf node and at least one of the semantic ids of the parse node belong to a verb
|
|
20
|
+
* synset and the semantic role of the node is PREDICATE, false otherwise.
|
|
21
|
+
*/
|
|
11
22
|
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
12
23
|
let layerInfo = parseNode.getLayerInfo();
|
|
13
24
|
return super.satisfies(parseNode)
|
|
@@ -3,6 +3,11 @@ import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
|
3
3
|
|
|
4
4
|
export class IsProperNoun extends IsLeafNode{
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the node is a leaf node and its parent has the tag NNP or NNPS.
|
|
8
|
+
* @param parseNode Parse node to check.
|
|
9
|
+
* @return True if the node is a leaf node and its parent has the tag NNP or NNPS, false otherwise.
|
|
10
|
+
*/
|
|
6
11
|
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
7
12
|
if (super.satisfies(parseNode)){
|
|
8
13
|
let parentData = parseNode.getParent().getData().getName();
|
|
@@ -5,6 +5,11 @@ import {Word} from "nlptoolkit-dictionary/dist/Dictionary/Word";
|
|
|
5
5
|
|
|
6
6
|
export class IsPunctuationNode extends IsLeafNode{
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the node is a leaf node and contains punctuation as the data.
|
|
10
|
+
* @param parseNode Parse node to check.
|
|
11
|
+
* @return True if the node is a leaf node and contains punctuation as the data, false otherwise.
|
|
12
|
+
*/
|
|
8
13
|
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
9
14
|
if (super.satisfies(parseNode)){
|
|
10
15
|
let data = parseNode.getLayerData(ViewLayerType.ENGLISH_WORD);
|
|
@@ -13,6 +13,11 @@ export class IsTransferable extends IsLeafNode{
|
|
|
13
13
|
this.secondLanguage = secondLanguage
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the node is a leaf node and is not a None or Null node.
|
|
18
|
+
* @param parseNode Parse node to check.
|
|
19
|
+
* @return True if the node is a leaf node and is not a None or Null node, false otherwise.
|
|
20
|
+
*/
|
|
16
21
|
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
17
22
|
if (super.satisfies(parseNode)) {
|
|
18
23
|
if (new IsNoneNode(this.secondLanguage).satisfies(parseNode)){
|
|
@@ -4,6 +4,11 @@ import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
|
4
4
|
|
|
5
5
|
export class IsTurkishLeafNode extends IsLeafNode{
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the parse node is a leaf node and contains a valid Turkish word in its data.
|
|
9
|
+
* @param parseNode Parse node to check.
|
|
10
|
+
* @return True if the parse node is a leaf node and contains a valid Turkish word in its data; false otherwise.
|
|
11
|
+
*/
|
|
7
12
|
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
8
13
|
if (super.satisfies(parseNode)){
|
|
9
14
|
let data = parseNode.getLayerInfo().getLayerData(ViewLayerType.TURKISH_WORD);
|
|
@@ -3,6 +3,11 @@ import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
|
3
3
|
|
|
4
4
|
export class IsVPNode implements NodeDrawableCondition{
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the node is not a leaf node and its tag is VP.
|
|
8
|
+
* @param parseNode Parse node to check.
|
|
9
|
+
* @return True if the node is not a leaf node and its tag is VP, false otherwise.
|
|
10
|
+
*/
|
|
6
11
|
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
7
12
|
return parseNode.numberOfChildren() > 0 && parseNode.getData().isVP();
|
|
8
13
|
}
|
|
@@ -8,11 +8,21 @@ export class IsVerbNode extends IsLeafNode{
|
|
|
8
8
|
|
|
9
9
|
private wordNet: WordNet
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Stores the wordnet for checking the pos tag of the synset.
|
|
13
|
+
* @param wordNet Wordnet used for checking the pos tag of the synset.
|
|
14
|
+
*/
|
|
11
15
|
constructor(wordNet: WordNet) {
|
|
12
16
|
super();
|
|
13
17
|
this.wordNet = wordNet
|
|
14
18
|
}
|
|
15
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the node is a leaf node and at least one of the semantic ids of the parse node belong to a verb synset.
|
|
22
|
+
* @param parseNode Parse node to check.
|
|
23
|
+
* @return True if the node is a leaf node and at least one of the semantic ids of the parse node belong to a verb
|
|
24
|
+
* synset, false otherwise.
|
|
25
|
+
*/
|
|
16
26
|
satisfies(parseNode: ParseNodeDrawable): boolean {
|
|
17
27
|
let layerInfo = parseNode.getLayerInfo();
|
|
18
28
|
if (super.satisfies(parseNode) && layerInfo != null && layerInfo.getLayerData(ViewLayerType.SEMANTICS) != null){
|
|
@@ -7,10 +7,19 @@ export class ContainsLayerInformation implements LeafListCondition{
|
|
|
7
7
|
|
|
8
8
|
private readonly viewLayerType: ViewLayerType
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Constructor for ContainsLayerInformation class. Sets the viewLayerType attribute.
|
|
12
|
+
* @param viewLayerType Layer for which check is done.
|
|
13
|
+
*/
|
|
10
14
|
constructor(viewLayerType: ViewLayerType) {
|
|
11
15
|
this.viewLayerType = viewLayerType
|
|
12
16
|
}
|
|
13
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Checks if all leaf nodes in the leafList contains the given layer information.
|
|
20
|
+
* @param leafList Array list storing the leaf nodes.
|
|
21
|
+
* @return True if all leaf nodes in the leafList contains the given layer information, false otherwise.
|
|
22
|
+
*/
|
|
14
23
|
satisfies(leafList: Array<ParseNodeDrawable>): boolean {
|
|
15
24
|
for (let parseNode of leafList){
|
|
16
25
|
if (!parseNode.getLayerData(ViewLayerType.ENGLISH_WORD).includes("*")){
|
|
@@ -7,10 +7,19 @@ export class NotContainsLayerInformation implements LeafListCondition{
|
|
|
7
7
|
|
|
8
8
|
private readonly viewLayerType: ViewLayerType
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Constructor for NotContainsLayerInformation class. Sets the viewLayerType attribute.
|
|
12
|
+
* @param viewLayerType Layer for which check is done.
|
|
13
|
+
*/
|
|
10
14
|
constructor(viewLayerType: ViewLayerType) {
|
|
11
15
|
this.viewLayerType = viewLayerType
|
|
12
16
|
}
|
|
13
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Checks if none of the leaf nodes in the leafList contains the given layer information.
|
|
20
|
+
* @param leafList Array list storing the leaf nodes.
|
|
21
|
+
* @return True if none of the leaf nodes in the leafList contains the given layer information, false otherwise.
|
|
22
|
+
*/
|
|
14
23
|
satisfies(leafList: Array<ParseNodeDrawable>): boolean {
|
|
15
24
|
for (let parseNode of leafList){
|
|
16
25
|
if (!parseNode.getLayerData(ViewLayerType.ENGLISH_WORD).includes("*")) {
|
|
@@ -7,10 +7,20 @@ export class SemiContainsLayerInformation implements LeafListCondition{
|
|
|
7
7
|
|
|
8
8
|
private readonly viewLayerType: ViewLayerType
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Constructor for SemiContainsLayerInformation class. Sets the viewLayerType attribute.
|
|
12
|
+
* @param viewLayerType Layer for which check is done.
|
|
13
|
+
*/
|
|
10
14
|
constructor(viewLayerType: ViewLayerType) {
|
|
11
15
|
this.viewLayerType = viewLayerType
|
|
12
16
|
}
|
|
13
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Checks if some (but not all) of the leaf nodes in the leafList contains the given layer information.
|
|
20
|
+
* @param leafList Array list storing the leaf nodes.
|
|
21
|
+
* @return True if some (but not all) of the leaf nodes in the leafList contains the given layer information, false
|
|
22
|
+
* otherwise.
|
|
23
|
+
*/
|
|
14
24
|
satisfies(leafList: Array<ParseNodeDrawable>): boolean {
|
|
15
25
|
let notDone = 0, done = 0;
|
|
16
26
|
for (let parseNode of leafList){
|
|
@@ -3,6 +3,9 @@ import {LeafToLanguageConverter} from "./LeafToLanguageConverter";
|
|
|
3
3
|
|
|
4
4
|
export class LeafToEnglish extends LeafToLanguageConverter{
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Constructor for LeafToEnglish. Sets viewLayerType to ENGLISH.
|
|
8
|
+
*/
|
|
6
9
|
constructor() {
|
|
7
10
|
super()
|
|
8
11
|
this.viewLayerType = ViewLayerType.ENGLISH_WORD;
|
|
@@ -6,6 +6,13 @@ export class LeafToLanguageConverter implements LeafToStringConverter{
|
|
|
6
6
|
|
|
7
7
|
protected viewLayerType: ViewLayerType
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Converts the data in the leaf node to string, except shortcuts to parentheses are converted to its normal forms,
|
|
11
|
+
* '*', '0', '-NONE-' are converted to empty string.
|
|
12
|
+
* @param leafNode Node to be converted to string.
|
|
13
|
+
* @return String form of the data, except shortcuts to parentheses are converted to its normal forms,
|
|
14
|
+
* '*', '0', '-NONE-' are converted to empty string.
|
|
15
|
+
*/
|
|
9
16
|
leafConverter(leafNode: ParseNodeDrawable): string {
|
|
10
17
|
let layerData = leafNode.getLayerData(this.viewLayerType);
|
|
11
18
|
let parentLayerData = (<ParseNodeDrawable>leafNode.getParent()).getLayerData(this.viewLayerType);
|
|
@@ -3,6 +3,9 @@ import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
|
3
3
|
|
|
4
4
|
export class LeafToPersian extends LeafToLanguageConverter{
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Constructor for LeafToPersian. Sets viewLayerType to PERSIAN.
|
|
8
|
+
*/
|
|
6
9
|
constructor() {
|
|
7
10
|
super();
|
|
8
11
|
this.viewLayerType = ViewLayerType.PERSIAN_WORD
|
|
@@ -3,6 +3,13 @@ import {ParseNodeDrawable} from "../../ParseNodeDrawable";
|
|
|
3
3
|
|
|
4
4
|
export class LeafToRootFormConverter implements LeafToStringConverter{
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Converts the data in the leaf node to string. If there are multiple words in the leaf node, they are concatenated
|
|
8
|
+
* with space.
|
|
9
|
+
* @param parseNodeDrawable Node to be converted to string.
|
|
10
|
+
* @return String form of the data. If there are multiple words in the leaf node, they are concatenated
|
|
11
|
+
* with space.
|
|
12
|
+
*/
|
|
6
13
|
leafConverter(parseNodeDrawable: ParseNodeDrawable): string {
|
|
7
14
|
let layerInfo = parseNodeDrawable.getLayerInfo();
|
|
8
15
|
let rootWords = " ";
|
|
@@ -3,6 +3,9 @@ import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
|
3
3
|
|
|
4
4
|
export class LeafToTurkish extends LeafToLanguageConverter{
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Constructor for LeafToPersian. Sets viewLayerType to TURKISH.
|
|
8
|
+
*/
|
|
6
9
|
constructor() {
|
|
7
10
|
super();
|
|
8
11
|
this.viewLayerType = ViewLayerType.TURKISH_WORD
|
|
@@ -6,11 +6,23 @@ export class NodeDrawableCollector {
|
|
|
6
6
|
private condition: NodeDrawableCondition
|
|
7
7
|
private rootNode: ParseNodeDrawable
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Constructor for the NodeDrawableCollector class. NodeDrawableCollector's main aim is to collect a set of
|
|
11
|
+
* ParseNode's from a subtree rooted at rootNode, where the ParseNode's satisfy a given NodeCondition, which is
|
|
12
|
+
* implemented by other interface class.
|
|
13
|
+
* @param rootNode Root node of the subtree
|
|
14
|
+
* @param condition The condition interface for which all nodes in the subtree rooted at rootNode will be checked
|
|
15
|
+
*/
|
|
9
16
|
constructor(rootNode: ParseNodeDrawable, condition: NodeDrawableCondition) {
|
|
10
17
|
this.rootNode = rootNode
|
|
11
18
|
this.condition = condition
|
|
12
19
|
}
|
|
13
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Private recursive method to check all descendants of the parseNode, if they ever satisfy the given node condition
|
|
23
|
+
* @param parseNode Root node of the subtree
|
|
24
|
+
* @param collected The {@link ArrayList} where the collected ParseNode's will be stored.
|
|
25
|
+
*/
|
|
14
26
|
private collectNodes(parseNode: ParseNodeDrawable, collected: Array<ParseNodeDrawable>){
|
|
15
27
|
if (this.condition == null || this.condition.satisfies(parseNode)){
|
|
16
28
|
collected.push(parseNode);
|
|
@@ -20,6 +32,10 @@ export class NodeDrawableCollector {
|
|
|
20
32
|
}
|
|
21
33
|
}
|
|
22
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Collects and returns all ParseNodes satisfying the node condition.
|
|
37
|
+
* @return All ParseNodes satisfying the node condition.
|
|
38
|
+
*/
|
|
23
39
|
collect(): Array<ParseNodeDrawable>{
|
|
24
40
|
let result = new Array<ParseNodeDrawable>();
|
|
25
41
|
this.collectNodes(this.rootNode, result);
|
|
@@ -7,11 +7,22 @@ export class TreeToStringConverter {
|
|
|
7
7
|
private converter: LeafToStringConverter
|
|
8
8
|
private parseTree: ParseTreeDrawable
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Constructor of the TreeToStringConverter class. Sets the attributes.
|
|
12
|
+
* @param parseTree Parse tree to be converted.
|
|
13
|
+
* @param converter Node to string converter interface.
|
|
14
|
+
*/
|
|
10
15
|
constructor(parseTree: ParseTreeDrawable, converter: LeafToStringConverter) {
|
|
11
16
|
this.converter = converter
|
|
12
17
|
this.parseTree = parseTree
|
|
13
18
|
}
|
|
14
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Converts recursively a parse node to a string. If it is a leaf node, calls the converter's leafConverter method,
|
|
22
|
+
* otherwise concatenates the converted strings of its children.
|
|
23
|
+
* @param parseNode Parse node to convert to string.
|
|
24
|
+
* @return String form of the parse node and all of its descendants.
|
|
25
|
+
*/
|
|
15
26
|
private convertToString(parseNode: ParseNodeDrawable): string{
|
|
16
27
|
if (parseNode.isLeaf()){
|
|
17
28
|
return this.converter.leafConverter(parseNode);
|
|
@@ -24,6 +35,10 @@ export class TreeToStringConverter {
|
|
|
24
35
|
}
|
|
25
36
|
}
|
|
26
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Calls the convertToString method with root of the tree to convert the parse tree to string.
|
|
40
|
+
* @return String form of the parse tree.
|
|
41
|
+
*/
|
|
27
42
|
convert(){
|
|
28
43
|
return this.convertToString(<ParseNodeDrawable> this.parseTree.getRoot());
|
|
29
44
|
}
|
|
@@ -6,6 +6,13 @@ import {ViewLayerType} from "nlptoolkit-annotatedsentence/dist/ViewLayerType";
|
|
|
6
6
|
|
|
7
7
|
export class TreeBankDrawable extends TreeBank{
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* A constructor of {@link TreeBankDrawable} class which reads all {@link ParseTreeDrawable} files with the file
|
|
11
|
+
* name satisfying the given pattern inside the given folder. For each file inside that folder, the constructor
|
|
12
|
+
* creates a ParseTreeDrawable and puts in inside the list parseTrees.
|
|
13
|
+
* @param folder Folder where all parseTrees reside.
|
|
14
|
+
* @param pattern File pattern such as "." ".train" ".test".
|
|
15
|
+
*/
|
|
9
16
|
constructor(folder?: string, pattern?: string) {
|
|
10
17
|
super();
|
|
11
18
|
let files = fs.readdirSync(folder);
|
|
@@ -24,14 +31,27 @@ export class TreeBankDrawable extends TreeBank{
|
|
|
24
31
|
}
|
|
25
32
|
}
|
|
26
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Accessor for the parseTrees attribute
|
|
36
|
+
* @return ParseTrees attribute
|
|
37
|
+
*/
|
|
27
38
|
getParseTrees(): Array<ParseTree>{
|
|
28
39
|
return this.parseTrees
|
|
29
40
|
}
|
|
30
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Accessor for a specific tree with the given position in the array.
|
|
44
|
+
* @param index Index of the parseTree.
|
|
45
|
+
* @return Tree that is in the position index
|
|
46
|
+
*/
|
|
31
47
|
get(index: number): ParseTreeDrawable{
|
|
32
48
|
return <ParseTreeDrawable> this.parseTrees[index];
|
|
33
49
|
}
|
|
34
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Clears the given layer for all nodes in all trees
|
|
53
|
+
* @param layerType Layer name
|
|
54
|
+
*/
|
|
35
55
|
clearLayer(layerType: ViewLayerType){
|
|
36
56
|
for (let tree of this.parseTrees){
|
|
37
57
|
let parseTree = <ParseTreeDrawable> tree;
|