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.
Files changed (198) hide show
  1. package/README.md +6 -1
  2. package/dist/Layer/DependencyLayer.d.ts +4 -0
  3. package/dist/Layer/DependencyLayer.js +4 -0
  4. package/dist/Layer/DependencyLayer.js.map +1 -1
  5. package/dist/Layer/EnglishPropbankLayer.d.ts +9 -0
  6. package/dist/Layer/EnglishPropbankLayer.js +9 -0
  7. package/dist/Layer/EnglishPropbankLayer.js.map +1 -1
  8. package/dist/Layer/EnglishSemanticLayer.d.ts +5 -0
  9. package/dist/Layer/EnglishSemanticLayer.js +5 -0
  10. package/dist/Layer/EnglishSemanticLayer.js.map +1 -1
  11. package/dist/Layer/EnglishWordLayer.d.ts +4 -0
  12. package/dist/Layer/EnglishWordLayer.js +4 -0
  13. package/dist/Layer/EnglishWordLayer.js.map +1 -1
  14. package/dist/Layer/MetaMorphemeLayer.d.ts +19 -0
  15. package/dist/Layer/MetaMorphemeLayer.js +19 -0
  16. package/dist/Layer/MetaMorphemeLayer.js.map +1 -1
  17. package/dist/Layer/MetaMorphemesMovedLayer.d.ts +20 -0
  18. package/dist/Layer/MetaMorphemesMovedLayer.js +20 -0
  19. package/dist/Layer/MetaMorphemesMovedLayer.js.map +1 -1
  20. package/dist/Layer/MorphologicalAnalysisLayer.d.ts +32 -0
  21. package/dist/Layer/MorphologicalAnalysisLayer.js +32 -0
  22. package/dist/Layer/MorphologicalAnalysisLayer.js.map +1 -1
  23. package/dist/Layer/MultiWordLayer.d.ts +9 -0
  24. package/dist/Layer/MultiWordLayer.js +9 -0
  25. package/dist/Layer/MultiWordLayer.js.map +1 -1
  26. package/dist/Layer/NERLayer.d.ts +14 -0
  27. package/dist/Layer/NERLayer.js +14 -0
  28. package/dist/Layer/NERLayer.js.map +1 -1
  29. package/dist/Layer/PersianWordLayer.d.ts +4 -0
  30. package/dist/Layer/PersianWordLayer.js +4 -0
  31. package/dist/Layer/PersianWordLayer.js.map +1 -1
  32. package/dist/Layer/ShallowParseLayer.d.ts +11 -0
  33. package/dist/Layer/ShallowParseLayer.js +11 -0
  34. package/dist/Layer/ShallowParseLayer.js.map +1 -1
  35. package/dist/Layer/SingleWordLayer.d.ts +4 -0
  36. package/dist/Layer/SingleWordLayer.js +4 -0
  37. package/dist/Layer/SingleWordLayer.js.map +1 -1
  38. package/dist/Layer/SourceLanguageWordLayer.d.ts +4 -0
  39. package/dist/Layer/SourceLanguageWordLayer.js +4 -0
  40. package/dist/Layer/SourceLanguageWordLayer.js.map +1 -1
  41. package/dist/Layer/TargetLanguageWordLayer.d.ts +10 -1
  42. package/dist/Layer/TargetLanguageWordLayer.js +9 -0
  43. package/dist/Layer/TargetLanguageWordLayer.js.map +1 -1
  44. package/dist/Layer/TurkishPropbankLayer.d.ts +18 -0
  45. package/dist/Layer/TurkishPropbankLayer.js +18 -0
  46. package/dist/Layer/TurkishPropbankLayer.js.map +1 -1
  47. package/dist/Layer/TurkishSemanticLayer.d.ts +11 -0
  48. package/dist/Layer/TurkishSemanticLayer.js +11 -0
  49. package/dist/Layer/TurkishSemanticLayer.js.map +1 -1
  50. package/dist/Layer/TurkishWordLayer.d.ts +4 -0
  51. package/dist/Layer/TurkishWordLayer.js +4 -0
  52. package/dist/Layer/TurkishWordLayer.js.map +1 -1
  53. package/dist/Layer/WordLayer.d.ts +12 -0
  54. package/dist/Layer/WordLayer.js +12 -0
  55. package/dist/Layer/WordLayer.js.map +1 -1
  56. package/dist/LayerInfo.d.ts +188 -0
  57. package/dist/LayerInfo.js +229 -63
  58. package/dist/LayerInfo.js.map +1 -1
  59. package/dist/ParseNodeDrawable.d.ts +102 -0
  60. package/dist/ParseNodeDrawable.js +102 -0
  61. package/dist/ParseNodeDrawable.js.map +1 -1
  62. package/dist/ParseTreeDrawable.d.ts +134 -0
  63. package/dist/ParseTreeDrawable.js +153 -16
  64. package/dist/ParseTreeDrawable.js.map +1 -1
  65. package/dist/Processor/Condition/IsDoubleNode.d.ts +6 -0
  66. package/dist/Processor/Condition/IsDoubleNode.js +6 -0
  67. package/dist/Processor/Condition/IsDoubleNode.js.map +1 -1
  68. package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.d.ts +6 -0
  69. package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.js +6 -0
  70. package/dist/Processor/Condition/IsDoubleNodeWithDifferentTags.js.map +1 -1
  71. package/dist/Processor/Condition/IsEnglishLeafNode.d.ts +5 -0
  72. package/dist/Processor/Condition/IsEnglishLeafNode.js +5 -0
  73. package/dist/Processor/Condition/IsEnglishLeafNode.js.map +1 -1
  74. package/dist/Processor/Condition/IsLeafNode.d.ts +5 -0
  75. package/dist/Processor/Condition/IsLeafNode.js +5 -0
  76. package/dist/Processor/Condition/IsLeafNode.js.map +1 -1
  77. package/dist/Processor/Condition/IsNodeWithPredicate.d.ts +11 -0
  78. package/dist/Processor/Condition/IsNodeWithPredicate.js +11 -0
  79. package/dist/Processor/Condition/IsNodeWithPredicate.js.map +1 -1
  80. package/dist/Processor/Condition/IsNodeWithSymbol.d.ts +9 -0
  81. package/dist/Processor/Condition/IsNodeWithSymbol.js +9 -0
  82. package/dist/Processor/Condition/IsNodeWithSymbol.js.map +1 -1
  83. package/dist/Processor/Condition/IsNodeWithSynSetId.d.ts +9 -0
  84. package/dist/Processor/Condition/IsNodeWithSynSetId.js +9 -0
  85. package/dist/Processor/Condition/IsNodeWithSynSetId.js.map +1 -1
  86. package/dist/Processor/Condition/IsNoneNode.d.ts +5 -0
  87. package/dist/Processor/Condition/IsNoneNode.js +5 -0
  88. package/dist/Processor/Condition/IsNoneNode.js.map +1 -1
  89. package/dist/Processor/Condition/IsNullElement.d.ts +6 -0
  90. package/dist/Processor/Condition/IsNullElement.js +6 -0
  91. package/dist/Processor/Condition/IsNullElement.js.map +1 -1
  92. package/dist/Processor/Condition/IsNumber.d.ts +6 -0
  93. package/dist/Processor/Condition/IsNumber.js +6 -0
  94. package/dist/Processor/Condition/IsNumber.js.map +1 -1
  95. package/dist/Processor/Condition/IsPredicateVerbNode.d.ts +11 -0
  96. package/dist/Processor/Condition/IsPredicateVerbNode.js +11 -0
  97. package/dist/Processor/Condition/IsPredicateVerbNode.js.map +1 -1
  98. package/dist/Processor/Condition/IsProperNoun.d.ts +5 -0
  99. package/dist/Processor/Condition/IsProperNoun.js +5 -0
  100. package/dist/Processor/Condition/IsProperNoun.js.map +1 -1
  101. package/dist/Processor/Condition/IsPunctuationNode.d.ts +5 -0
  102. package/dist/Processor/Condition/IsPunctuationNode.js +5 -0
  103. package/dist/Processor/Condition/IsPunctuationNode.js.map +1 -1
  104. package/dist/Processor/Condition/IsTransferable.d.ts +5 -0
  105. package/dist/Processor/Condition/IsTransferable.js +5 -0
  106. package/dist/Processor/Condition/IsTransferable.js.map +1 -1
  107. package/dist/Processor/Condition/IsTurkishLeafNode.d.ts +5 -0
  108. package/dist/Processor/Condition/IsTurkishLeafNode.js +5 -0
  109. package/dist/Processor/Condition/IsTurkishLeafNode.js.map +1 -1
  110. package/dist/Processor/Condition/IsVPNode.d.ts +5 -0
  111. package/dist/Processor/Condition/IsVPNode.js +5 -0
  112. package/dist/Processor/Condition/IsVPNode.js.map +1 -1
  113. package/dist/Processor/Condition/IsVerbNode.d.ts +10 -0
  114. package/dist/Processor/Condition/IsVerbNode.js +10 -0
  115. package/dist/Processor/Condition/IsVerbNode.js.map +1 -1
  116. package/dist/Processor/LayerExist/ContainsLayerInformation.d.ts +9 -0
  117. package/dist/Processor/LayerExist/ContainsLayerInformation.js +9 -0
  118. package/dist/Processor/LayerExist/ContainsLayerInformation.js.map +1 -1
  119. package/dist/Processor/LayerExist/NotContainsLayerInformation.d.ts +9 -0
  120. package/dist/Processor/LayerExist/NotContainsLayerInformation.js +9 -0
  121. package/dist/Processor/LayerExist/NotContainsLayerInformation.js.map +1 -1
  122. package/dist/Processor/LayerExist/SemiContainsLayerInformation.d.ts +10 -0
  123. package/dist/Processor/LayerExist/SemiContainsLayerInformation.js +10 -0
  124. package/dist/Processor/LayerExist/SemiContainsLayerInformation.js.map +1 -1
  125. package/dist/Processor/LeafConverter/LeafToEnglish.d.ts +3 -0
  126. package/dist/Processor/LeafConverter/LeafToEnglish.js +3 -0
  127. package/dist/Processor/LeafConverter/LeafToEnglish.js.map +1 -1
  128. package/dist/Processor/LeafConverter/LeafToLanguageConverter.d.ts +7 -0
  129. package/dist/Processor/LeafConverter/LeafToLanguageConverter.js +7 -0
  130. package/dist/Processor/LeafConverter/LeafToLanguageConverter.js.map +1 -1
  131. package/dist/Processor/LeafConverter/LeafToPersian.d.ts +3 -0
  132. package/dist/Processor/LeafConverter/LeafToPersian.js +3 -0
  133. package/dist/Processor/LeafConverter/LeafToPersian.js.map +1 -1
  134. package/dist/Processor/LeafConverter/LeafToRootFormConverter.d.ts +7 -0
  135. package/dist/Processor/LeafConverter/LeafToRootFormConverter.js +7 -0
  136. package/dist/Processor/LeafConverter/LeafToRootFormConverter.js.map +1 -1
  137. package/dist/Processor/LeafConverter/LeafToTurkish.d.ts +3 -0
  138. package/dist/Processor/LeafConverter/LeafToTurkish.js +3 -0
  139. package/dist/Processor/LeafConverter/LeafToTurkish.js.map +1 -1
  140. package/dist/Processor/NodeDrawableCollector.d.ts +16 -0
  141. package/dist/Processor/NodeDrawableCollector.js +16 -0
  142. package/dist/Processor/NodeDrawableCollector.js.map +1 -1
  143. package/dist/Processor/TreeToStringConverter.d.ts +15 -0
  144. package/dist/Processor/TreeToStringConverter.js +15 -0
  145. package/dist/Processor/TreeToStringConverter.js.map +1 -1
  146. package/dist/TreeBankDrawable.d.ts +20 -0
  147. package/dist/TreeBankDrawable.js +20 -0
  148. package/dist/TreeBankDrawable.js.map +1 -1
  149. package/package.json +14 -12
  150. package/source/Layer/DependencyLayer.ts +4 -0
  151. package/source/Layer/EnglishPropbankLayer.ts +9 -0
  152. package/source/Layer/EnglishSemanticLayer.ts +5 -0
  153. package/source/Layer/EnglishWordLayer.ts +4 -0
  154. package/source/Layer/MetaMorphemeLayer.ts +19 -0
  155. package/source/Layer/MetaMorphemesMovedLayer.ts +20 -0
  156. package/source/Layer/MorphologicalAnalysisLayer.ts +32 -0
  157. package/source/Layer/MultiWordLayer.ts +9 -0
  158. package/source/Layer/NERLayer.ts +14 -0
  159. package/source/Layer/PersianWordLayer.ts +4 -0
  160. package/source/Layer/ShallowParseLayer.ts +11 -0
  161. package/source/Layer/SingleWordLayer.ts +4 -0
  162. package/source/Layer/SourceLanguageWordLayer.ts +4 -0
  163. package/source/Layer/TargetLanguageWordLayer.ts +10 -1
  164. package/source/Layer/TurkishPropbankLayer.ts +18 -0
  165. package/source/Layer/TurkishSemanticLayer.ts +11 -0
  166. package/source/Layer/TurkishWordLayer.ts +4 -0
  167. package/source/Layer/WordLayer.ts +12 -0
  168. package/source/LayerInfo.ts +333 -155
  169. package/source/ParseNodeDrawable.ts +102 -0
  170. package/source/ParseTreeDrawable.ts +158 -16
  171. package/source/Processor/Condition/IsDoubleNode.ts +6 -0
  172. package/source/Processor/Condition/IsDoubleNodeWithDifferentTags.ts +6 -0
  173. package/source/Processor/Condition/IsEnglishLeafNode.ts +5 -0
  174. package/source/Processor/Condition/IsLeafNode.ts +5 -0
  175. package/source/Processor/Condition/IsNodeWithPredicate.ts +11 -0
  176. package/source/Processor/Condition/IsNodeWithSymbol.ts +9 -0
  177. package/source/Processor/Condition/IsNodeWithSynSetId.ts +9 -0
  178. package/source/Processor/Condition/IsNoneNode.ts +5 -0
  179. package/source/Processor/Condition/IsNullElement.ts +6 -0
  180. package/source/Processor/Condition/IsNumber.ts +6 -0
  181. package/source/Processor/Condition/IsPredicateVerbNode.ts +11 -0
  182. package/source/Processor/Condition/IsProperNoun.ts +5 -0
  183. package/source/Processor/Condition/IsPunctuationNode.ts +5 -0
  184. package/source/Processor/Condition/IsTransferable.ts +5 -0
  185. package/source/Processor/Condition/IsTurkishLeafNode.ts +5 -0
  186. package/source/Processor/Condition/IsVPNode.ts +5 -0
  187. package/source/Processor/Condition/IsVerbNode.ts +10 -0
  188. package/source/Processor/LayerExist/ContainsLayerInformation.ts +9 -0
  189. package/source/Processor/LayerExist/NotContainsLayerInformation.ts +9 -0
  190. package/source/Processor/LayerExist/SemiContainsLayerInformation.ts +10 -0
  191. package/source/Processor/LeafConverter/LeafToEnglish.ts +3 -0
  192. package/source/Processor/LeafConverter/LeafToLanguageConverter.ts +7 -0
  193. package/source/Processor/LeafConverter/LeafToPersian.ts +3 -0
  194. package/source/Processor/LeafConverter/LeafToRootFormConverter.ts +7 -0
  195. package/source/Processor/LeafConverter/LeafToTurkish.ts +3 -0
  196. package/source/Processor/NodeDrawableCollector.ts +16 -0
  197. package/source/Processor/TreeToStringConverter.ts +15 -0
  198. 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;