nlptoolkit-universaldependencyparser 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.
Files changed (112) hide show
  1. package/dist/Agenda.d.ts +24 -0
  2. package/dist/Agenda.js +72 -0
  3. package/dist/Agenda.js.map +1 -0
  4. package/dist/ArcEagerInstanceGenerator.d.ts +20 -0
  5. package/dist/ArcEagerInstanceGenerator.js +81 -0
  6. package/dist/ArcEagerInstanceGenerator.js.map +1 -0
  7. package/dist/ArcEagerOracle.d.ts +9 -0
  8. package/dist/ArcEagerOracle.js +39 -0
  9. package/dist/ArcEagerOracle.js.map +1 -0
  10. package/dist/ArcEagerTransitionParser.d.ts +9 -0
  11. package/dist/ArcEagerTransitionParser.js +113 -0
  12. package/dist/ArcEagerTransitionParser.js.map +1 -0
  13. package/dist/ArcStandardOracle.d.ts +9 -0
  14. package/dist/ArcStandardOracle.js +36 -0
  15. package/dist/ArcStandardOracle.js.map +1 -0
  16. package/dist/ArcStandardTransitionParser.d.ts +28 -0
  17. package/dist/ArcStandardTransitionParser.js +129 -0
  18. package/dist/ArcStandardTransitionParser.js.map +1 -0
  19. package/dist/Candidate.d.ts +8 -0
  20. package/dist/Candidate.js +27 -0
  21. package/dist/Candidate.js.map +1 -0
  22. package/dist/Command.d.ts +6 -0
  23. package/dist/Command.js +8 -0
  24. package/dist/Command.js.map +1 -0
  25. package/dist/Decision.d.ts +7 -0
  26. package/dist/Decision.js +25 -0
  27. package/dist/Decision.js.map +1 -0
  28. package/dist/InstanceGenerator.d.ts +33 -0
  29. package/dist/InstanceGenerator.js +77 -0
  30. package/dist/InstanceGenerator.js.map +1 -0
  31. package/dist/Oracle.d.ts +49 -0
  32. package/dist/Oracle.js +115 -0
  33. package/dist/Oracle.js.map +1 -0
  34. package/dist/RandomOracle.d.ts +14 -0
  35. package/dist/RandomOracle.js +45 -0
  36. package/dist/RandomOracle.js.map +1 -0
  37. package/dist/RandomScoringOracle.d.ts +5 -0
  38. package/dist/RandomScoringOracle.js +21 -0
  39. package/dist/RandomScoringOracle.js.map +1 -0
  40. package/dist/ScoringOracle.d.ts +4 -0
  41. package/dist/ScoringOracle.js +17 -0
  42. package/dist/ScoringOracle.js.map +1 -0
  43. package/dist/SimpleInstanceGenerator.d.ts +14 -0
  44. package/dist/SimpleInstanceGenerator.js +67 -0
  45. package/dist/SimpleInstanceGenerator.js.map +1 -0
  46. package/dist/StackRelation.d.ts +10 -0
  47. package/dist/StackRelation.js +30 -0
  48. package/dist/StackRelation.js.map +1 -0
  49. package/dist/StackWord.d.ts +11 -0
  50. package/dist/StackWord.js +42 -0
  51. package/dist/StackWord.js.map +1 -0
  52. package/dist/State.d.ts +25 -0
  53. package/dist/State.js +161 -0
  54. package/dist/State.js.map +1 -0
  55. package/dist/TransitionParser.d.ts +73 -0
  56. package/dist/TransitionParser.js +164 -0
  57. package/dist/TransitionParser.js.map +1 -0
  58. package/dist/TransitionSystem.d.ts +4 -0
  59. package/dist/TransitionSystem.js +6 -0
  60. package/dist/TransitionSystem.js.map +1 -0
  61. package/index.js +20 -0
  62. package/models/en_atis_eager_c45_2.txt +1903 -0
  63. package/models/en_atis_eager_c45_3.txt +1918 -0
  64. package/models/en_atis_standard_c45_2.txt +1948 -0
  65. package/models/en_atis_standard_c45_3.txt +2233 -0
  66. package/models/tr_atis_eager_c45_2.txt +2208 -0
  67. package/models/tr_atis_eager_c45_3.txt +2303 -0
  68. package/models/tr_atis_standard_c45_2.txt +2863 -0
  69. package/models/tr_atis_standard_c45_3.txt +3413 -0
  70. package/models/tr_boun_eager_c45_2.txt +1613 -0
  71. package/models/tr_boun_eager_c45_3.txt +1818 -0
  72. package/models/tr_boun_standard_c45_2.txt +898 -0
  73. package/models/tr_boun_standard_c45_3.txt +1138 -0
  74. package/models/tr_framenet_eager_c45_2.txt +453 -0
  75. package/models/tr_framenet_eager_c45_3.txt +668 -0
  76. package/models/tr_framenet_standard_c45_2.txt +363 -0
  77. package/models/tr_framenet_standard_c45_3.txt +238 -0
  78. package/models/tr_kenet_eager_c45_2.txt +1788 -0
  79. package/models/tr_kenet_eager_c45_3.txt +1588 -0
  80. package/models/tr_kenet_standard_c45_2.txt +1308 -0
  81. package/models/tr_kenet_standard_c45_3.txt +1378 -0
  82. package/models/tr_penn_eager_c45_2.txt +2788 -0
  83. package/models/tr_penn_eager_c45_3.txt +1718 -0
  84. package/models/tr_penn_standard_c45_2.txt +2203 -0
  85. package/models/tr_penn_standard_c45_3.txt +1493 -0
  86. package/models/tr_tourism_eager_c45_2.txt +3468 -0
  87. package/models/tr_tourism_eager_c45_3.txt +4213 -0
  88. package/models/tr_tourism_standard_c45_2.txt +3868 -0
  89. package/models/tr_tourism_standard_c45_3.txt +4728 -0
  90. package/package.json +30 -0
  91. package/source/Parser/TransitionBasedParser/Agenda.ts +66 -0
  92. package/source/Parser/TransitionBasedParser/ArcEagerInstanceGenerator.ts +73 -0
  93. package/source/Parser/TransitionBasedParser/ArcEagerOracle.ts +30 -0
  94. package/source/Parser/TransitionBasedParser/ArcEagerTransitionParser.ts +105 -0
  95. package/source/Parser/TransitionBasedParser/ArcStandardOracle.ts +28 -0
  96. package/source/Parser/TransitionBasedParser/ArcStandardTransitionParser.ts +123 -0
  97. package/source/Parser/TransitionBasedParser/Candidate.ts +20 -0
  98. package/source/Parser/TransitionBasedParser/Command.ts +3 -0
  99. package/source/Parser/TransitionBasedParser/Decision.ts +16 -0
  100. package/source/Parser/TransitionBasedParser/InstanceGenerator.ts +85 -0
  101. package/source/Parser/TransitionBasedParser/Oracle.ts +123 -0
  102. package/source/Parser/TransitionBasedParser/RandomOracle.ts +37 -0
  103. package/source/Parser/TransitionBasedParser/RandomScoringOracle.ts +10 -0
  104. package/source/Parser/TransitionBasedParser/ScoringOracle.ts +5 -0
  105. package/source/Parser/TransitionBasedParser/SimpleInstanceGenerator.ts +57 -0
  106. package/source/Parser/TransitionBasedParser/StackRelation.ts +27 -0
  107. package/source/Parser/TransitionBasedParser/StackWord.ts +38 -0
  108. package/source/Parser/TransitionBasedParser/State.ts +168 -0
  109. package/source/Parser/TransitionBasedParser/TransitionParser.ts +187 -0
  110. package/source/Parser/TransitionBasedParser/TransitionSystem.ts +3 -0
  111. package/source/tsconfig.json +13 -0
  112. package/tsconfig.json +15 -0
@@ -0,0 +1,27 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Candidate = void 0;
13
+ class Candidate {
14
+ constructor(command, universalDependencyType) {
15
+ this.command = command;
16
+ this.universalDependencyType = universalDependencyType;
17
+ }
18
+ getCommand() {
19
+ return this.command;
20
+ }
21
+ getUniversalDependencyType() {
22
+ return this.universalDependencyType;
23
+ }
24
+ }
25
+ exports.Candidate = Candidate;
26
+ });
27
+ //# sourceMappingURL=Candidate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Candidate.js","sourceRoot":"","sources":["../source/Parser/TransitionBasedParser/Candidate.ts"],"names":[],"mappings":";;;;;;;;;;;;IAEA,MAAa,SAAS;QAIlB,YAAY,OAAgB,EAAE,uBAAgD;YAC1E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;YACtB,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAA;QAC1D,CAAC;QAED,UAAU;YACN,OAAO,IAAI,CAAC,OAAO,CAAA;QACvB,CAAC;QAED,0BAA0B;YACtB,OAAO,IAAI,CAAC,uBAAuB,CAAA;QACvC,CAAC;KAEJ;IAjBD,8BAiBC"}
@@ -0,0 +1,6 @@
1
+ declare enum Command {
2
+ RIGHTARC = 0,
3
+ LEFTARC = 1,
4
+ SHIFT = 2,
5
+ REDUCE = 3
6
+ }
@@ -0,0 +1,8 @@
1
+ var Command;
2
+ (function (Command) {
3
+ Command[Command["RIGHTARC"] = 0] = "RIGHTARC";
4
+ Command[Command["LEFTARC"] = 1] = "LEFTARC";
5
+ Command[Command["SHIFT"] = 2] = "SHIFT";
6
+ Command[Command["REDUCE"] = 3] = "REDUCE";
7
+ })(Command || (Command = {}));
8
+ //# sourceMappingURL=Command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Command.js","sourceRoot":"","sources":["../source/Parser/TransitionBasedParser/Command.ts"],"names":[],"mappings":"AAAA,IAAK,OAEJ;AAFD,WAAK,OAAO;IACR,6CAAQ,CAAA;IAAE,2CAAO,CAAA;IAAE,uCAAK,CAAA;IAAE,yCAAM,CAAA;AACpC,CAAC,EAFI,OAAO,KAAP,OAAO,QAEX"}
@@ -0,0 +1,7 @@
1
+ import { UniversalDependencyType } from "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyType";
2
+ import { Candidate } from "./Candidate";
3
+ export declare class Decision extends Candidate {
4
+ private readonly point;
5
+ constructor(command: Command, universalDependencyType: UniversalDependencyType, point: number);
6
+ getPoint(): number;
7
+ }
@@ -0,0 +1,25 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./Candidate"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Decision = void 0;
13
+ const Candidate_1 = require("./Candidate");
14
+ class Decision extends Candidate_1.Candidate {
15
+ constructor(command, universalDependencyType, point) {
16
+ super(command, universalDependencyType);
17
+ this.point = point;
18
+ }
19
+ getPoint() {
20
+ return this.point;
21
+ }
22
+ }
23
+ exports.Decision = Decision;
24
+ });
25
+ //# sourceMappingURL=Decision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Decision.js","sourceRoot":"","sources":["../source/Parser/TransitionBasedParser/Decision.ts"],"names":[],"mappings":";;;;;;;;;;;;IACA,2CAAsC;IAEtC,MAAa,QAAS,SAAQ,qBAAS;QAInC,YAAY,OAAgB,EAAE,uBAAgD,EAAE,KAAa;YACzF,KAAK,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;YACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACtB,CAAC;QAED,QAAQ;YACJ,OAAO,IAAI,CAAC,KAAK,CAAA;QACrB,CAAC;KACJ;IAZD,4BAYC"}
@@ -0,0 +1,33 @@
1
+ import { State } from "./State";
2
+ import { UniversalDependencyTreeBankWord } from "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyTreeBankWord";
3
+ import { Attribute } from "nlptoolkit-classification/dist/Attribute/Attribute";
4
+ import { Instance } from "nlptoolkit-classification/dist/Instance/Instance";
5
+ export declare abstract class InstanceGenerator {
6
+ /**
7
+ * Abstract method for generating an instance based on the current state, window size, and command.
8
+ * @param state The current state of the parser.
9
+ * @param windowSize The size of the window used for feature extraction.
10
+ * @param command The command to be used for generating the instance.
11
+ * @return The generated {@link Instance} object.
12
+ */
13
+ abstract generate(state: State, windowSize: number, command: string): Instance;
14
+ /**
15
+ * Adds an attribute for a specific feature type of a given word to the list of attributes.
16
+ * @param word The word whose feature value is used to create the attribute.
17
+ * @param attributes The list of attributes to which the new attribute will be added.
18
+ * @param featureType The type of the feature to be extracted from the word.
19
+ */
20
+ private addAttributeForFeatureType;
21
+ /**
22
+ * Adds a set of default (empty) attributes to the list of attributes. These attributes represent
23
+ * various feature types with default "null" values.
24
+ * @param attributes The list of attributes to which the default attributes will be added.
25
+ */
26
+ protected addEmptyAttributes(attributes: Array<Attribute>): void;
27
+ /**
28
+ * Adds attributes for various feature types of a given word to the list of attributes.
29
+ * @param word The word whose feature values are used to create the attributes.
30
+ * @param attributes The list of attributes to which the new attributes will be added.
31
+ */
32
+ protected addFeatureAttributes(word: UniversalDependencyTreeBankWord, attributes: Array<Attribute>): void;
33
+ }
@@ -0,0 +1,77 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyTreeBankFeatures", "nlptoolkit-classification/dist/Attribute/DiscreteIndexedAttribute"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.InstanceGenerator = void 0;
13
+ const UniversalDependencyTreeBankFeatures_1 = require("nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyTreeBankFeatures");
14
+ const DiscreteIndexedAttribute_1 = require("nlptoolkit-classification/dist/Attribute/DiscreteIndexedAttribute");
15
+ class InstanceGenerator {
16
+ /**
17
+ * Adds an attribute for a specific feature type of a given word to the list of attributes.
18
+ * @param word The word whose feature value is used to create the attribute.
19
+ * @param attributes The list of attributes to which the new attribute will be added.
20
+ * @param featureType The type of the feature to be extracted from the word.
21
+ */
22
+ addAttributeForFeatureType(word, attributes, featureType) {
23
+ let feature = word.getFeatureValue(featureType);
24
+ let numberOfValues = UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", featureType) + 1;
25
+ if (feature != undefined) {
26
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute(feature, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.featureValueIndex("tr", featureType, feature) + 1, numberOfValues));
27
+ }
28
+ else {
29
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, numberOfValues));
30
+ }
31
+ }
32
+ /**
33
+ * Adds a set of default (empty) attributes to the list of attributes. These attributes represent
34
+ * various feature types with default "null" values.
35
+ * @param attributes The list of attributes to which the default attributes will be added.
36
+ */
37
+ addEmptyAttributes(attributes) {
38
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "PronType") + 1));
39
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "NumType") + 1));
40
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Number") + 1));
41
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Case") + 1));
42
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Definite") + 1));
43
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Degree") + 1));
44
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "VerbForm") + 1));
45
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Mood") + 1));
46
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Tense") + 1));
47
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Aspect") + 1));
48
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Voice") + 1));
49
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Evident") + 1));
50
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Polarity") + 1));
51
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.numberOfValues("tr", "Person") + 1));
52
+ }
53
+ /**
54
+ * Adds attributes for various feature types of a given word to the list of attributes.
55
+ * @param word The word whose feature values are used to create the attributes.
56
+ * @param attributes The list of attributes to which the new attributes will be added.
57
+ */
58
+ addFeatureAttributes(word, attributes) {
59
+ this.addAttributeForFeatureType(word, attributes, "PronType");
60
+ this.addAttributeForFeatureType(word, attributes, "NumType");
61
+ this.addAttributeForFeatureType(word, attributes, "Number");
62
+ this.addAttributeForFeatureType(word, attributes, "Case");
63
+ this.addAttributeForFeatureType(word, attributes, "Definite");
64
+ this.addAttributeForFeatureType(word, attributes, "Degree");
65
+ this.addAttributeForFeatureType(word, attributes, "VerbForm");
66
+ this.addAttributeForFeatureType(word, attributes, "Mood");
67
+ this.addAttributeForFeatureType(word, attributes, "Tense");
68
+ this.addAttributeForFeatureType(word, attributes, "Aspect");
69
+ this.addAttributeForFeatureType(word, attributes, "Voice");
70
+ this.addAttributeForFeatureType(word, attributes, "Evident");
71
+ this.addAttributeForFeatureType(word, attributes, "Polarity");
72
+ this.addAttributeForFeatureType(word, attributes, "Person");
73
+ }
74
+ }
75
+ exports.InstanceGenerator = InstanceGenerator;
76
+ });
77
+ //# sourceMappingURL=InstanceGenerator.js.map
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AE,OAAO,CAAC,CAAA;YAC1D,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC3D,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;YAC1D,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;YAC5D,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;YAC7D,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAA;QAC/D,CAAC;KACJ;IAzED,8CAyEC"}
@@ -0,0 +1,49 @@
1
+ import { Model } from "nlptoolkit-classification/dist/Model/Model";
2
+ import { Decision } from "./Decision";
3
+ import { State } from "./State";
4
+ import { Candidate } from "./Candidate";
5
+ export declare abstract class Oracle {
6
+ protected commandModel: Model;
7
+ protected windowSize: number;
8
+ /**
9
+ * Constructs an Oracle with the given model and window size.
10
+ * @param model the model used for making predictions
11
+ * @param windowSize the size of the window used in parsing
12
+ */
13
+ protected constructor(model: Model, windowSize: number);
14
+ /**
15
+ * Abstract method to be implemented by subclasses to make a parsing decision based on the current state.
16
+ * @param state the current parsing state
17
+ * @return a {@link Decision} object representing the action to be taken
18
+ */
19
+ abstract makeDecision(state: State): Decision;
20
+ /**
21
+ * Abstract method to be implemented by subclasses to score potential decisions based on the current state and transition system.
22
+ * @param state the current parsing state
23
+ * @param transitionSystem the transition system being used (e.g., ARC_STANDARD or ARC_EAGER)
24
+ * @return a list of {@link Decision} objects, each with a score indicating its suitability
25
+ */
26
+ protected abstract scoreDecisions(state: State, transitionSystem: TransitionSystem): Array<Decision>;
27
+ /**
28
+ * Finds the best valid parsing action for the ARC_EAGER transition system based on probabilities.
29
+ * Ensures the action is applicable given the current state.
30
+ * @param probabilities a map of actions to their associated probabilities
31
+ * @param state the current parsing state
32
+ * @return the best action as a string, or an empty string if no valid action is found
33
+ */
34
+ protected findBestValidEagerClassInfo(probabilities: Map<string, number>, state: State): string;
35
+ /**
36
+ * Finds the best valid parsing action for the ARC_STANDARD transition system based on probabilities.
37
+ * Ensures the action is applicable given the current state.
38
+ * @param probabilities a map of actions to their associated probabilities
39
+ * @param state the current parsing state
40
+ * @return the best action as a string, or an empty string if no valid action is found
41
+ */
42
+ protected findBestValidStandardClassInfo(probabilities: Map<string, number>, state: State): string;
43
+ /**
44
+ * Converts a string representation of the best action into a {@link Candidate} object.
45
+ * @param best the best action represented as a string, possibly with a dependency type in parentheses
46
+ * @return a {@link Candidate} object representing the action, or null if the action is unknown
47
+ */
48
+ protected getDecisionCandidate(best: string): Candidate;
49
+ }
package/dist/Oracle.js ADDED
@@ -0,0 +1,115 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./Candidate", "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyRelation", "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyType"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Oracle = void 0;
13
+ const Candidate_1 = require("./Candidate");
14
+ const UniversalDependencyRelation_1 = require("nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyRelation");
15
+ const UniversalDependencyType_1 = require("nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyType");
16
+ class Oracle {
17
+ /**
18
+ * Constructs an Oracle with the given model and window size.
19
+ * @param model the model used for making predictions
20
+ * @param windowSize the size of the window used in parsing
21
+ */
22
+ constructor(model, windowSize) {
23
+ this.commandModel = model;
24
+ this.windowSize = windowSize;
25
+ }
26
+ /**
27
+ * Finds the best valid parsing action for the ARC_EAGER transition system based on probabilities.
28
+ * Ensures the action is applicable given the current state.
29
+ * @param probabilities a map of actions to their associated probabilities
30
+ * @param state the current parsing state
31
+ * @return the best action as a string, or an empty string if no valid action is found
32
+ */
33
+ findBestValidEagerClassInfo(probabilities, state) {
34
+ let bestValue = 0.0;
35
+ let best = "";
36
+ for (let key in probabilities) {
37
+ if (probabilities.get(key) > bestValue) {
38
+ if (key == "SHIFT" || key == "RIGHTARC") {
39
+ if (state.wordListSize() > 0) {
40
+ best = key;
41
+ bestValue = probabilities.get(key);
42
+ }
43
+ }
44
+ else {
45
+ if (state.stackSize() > 1) {
46
+ if (!(key == "REDUCE" && state.getPeek().getRelation() == null)) {
47
+ best = key;
48
+ bestValue = probabilities.get(key);
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ return best;
55
+ }
56
+ /**
57
+ * Finds the best valid parsing action for the ARC_STANDARD transition system based on probabilities.
58
+ * Ensures the action is applicable given the current state.
59
+ * @param probabilities a map of actions to their associated probabilities
60
+ * @param state the current parsing state
61
+ * @return the best action as a string, or an empty string if no valid action is found
62
+ */
63
+ findBestValidStandardClassInfo(probabilities, state) {
64
+ let bestValue = 0.0;
65
+ let best = "";
66
+ for (let key in probabilities) {
67
+ if (probabilities.get(key) > bestValue) {
68
+ if (key == "SHIFT") {
69
+ if (state.wordListSize() > 0) {
70
+ best = key;
71
+ bestValue = probabilities.get(key);
72
+ }
73
+ }
74
+ else {
75
+ if (state.stackSize() > 1) {
76
+ best = key;
77
+ bestValue = probabilities.get(key);
78
+ }
79
+ }
80
+ }
81
+ }
82
+ return best;
83
+ }
84
+ /**
85
+ * Converts a string representation of the best action into a {@link Candidate} object.
86
+ * @param best the best action represented as a string, possibly with a dependency type in parentheses
87
+ * @return a {@link Candidate} object representing the action, or null if the action is unknown
88
+ */
89
+ getDecisionCandidate(best) {
90
+ let command, type;
91
+ if (best.includes("(")) {
92
+ command = best.substring(0, best.indexOf('('));
93
+ let relation = best.substring(best.indexOf('(') + 1, best.indexOf(')'));
94
+ type = UniversalDependencyRelation_1.UniversalDependencyRelation.getDependencyTag(relation);
95
+ }
96
+ else {
97
+ command = best;
98
+ type = UniversalDependencyType_1.UniversalDependencyType.DEP;
99
+ }
100
+ switch (command) {
101
+ case "SHIFT":
102
+ return new Candidate_1.Candidate(Command.SHIFT, type);
103
+ case "REDUCE":
104
+ return new Candidate_1.Candidate(Command.REDUCE, type);
105
+ case "LEFTARC":
106
+ return new Candidate_1.Candidate(Command.LEFTARC, type);
107
+ case "RIGHTARC":
108
+ return new Candidate_1.Candidate(Command.RIGHTARC, type);
109
+ }
110
+ return null;
111
+ }
112
+ }
113
+ exports.Oracle = Oracle;
114
+ });
115
+ //# sourceMappingURL=Oracle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Oracle.js","sourceRoot":"","sources":["../source/Parser/TransitionBasedParser/Oracle.ts"],"names":[],"mappings":";;;;;;;;;;;;IAGA,2CAAsC;IACtC,wHAAmH;IACnH,gHAA2G;IAE3G,MAAsB,MAAM;QAKxB;;;;WAIG;QACH,YAAsB,KAAY,EAAE,UAAkB;YAClD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;YACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAChC,CAAC;QAiBD;;;;;;WAMG;QACO,2BAA2B,CAAC,aAAkC,EAAE,KAAY;YAClF,IAAI,SAAS,GAAG,GAAG,CAAA;YACnB,IAAI,IAAI,GAAG,EAAE,CAAA;YACb,KAAK,IAAI,GAAG,IAAI,aAAa,EAAC;gBAC1B,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,EAAC;oBACnC,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,IAAI,UAAU,EAAC;wBACpC,IAAI,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,EAAC;4BACzB,IAAI,GAAG,GAAG,CAAA;4BACV,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;yBACrC;qBACJ;yBAAM;wBACH,IAAI,KAAK,CAAC,SAAS,E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AC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;gBACvE,IAAI,GAAG,yDAA2B,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;aAChE;iBAAM;gBACH,OAAO,GAAG,IAAI,CAAA;gBACd,IAAI,GAAG,iDAAuB,CAAC,GAAG,CAAA;aACrC;YACD,QAAQ,OAAO,EAAC;gBACZ,KAAK,OAAO;oBACR,OAAO,IAAI,qBAAS,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;gBAC7C,KAAK,QAAQ;oBACT,OAAO,IAAI,qBAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;gBAC9C,KAAK,SAAS;oBACV,OAAO,IAAI,qBAAS,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;gBAC/C,KAAK,UAAU;oBACX,OAAO,IAAI,qBAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;aACnD;YACD,OAAO,IAAI,CAAA;QACf,CAAC;KACJ;IAnHD,wBAmHC"}
@@ -0,0 +1,14 @@
1
+ import { Oracle } from "./Oracle";
2
+ import { State } from "./State";
3
+ import { Decision } from "./Decision";
4
+ import { Model } from "nlptoolkit-classification/dist/Model/Model";
5
+ export declare class RandomOracle extends Oracle {
6
+ constructor(model: Model, windowSize: number);
7
+ /**
8
+ * Makes a random decision based on a uniform distribution over possible actions.
9
+ * @param state The current state of the parser.
10
+ * @return A Decision object representing the randomly chosen action.
11
+ */
12
+ makeDecision(state: State): Decision;
13
+ protected scoreDecisions(state: State, transitionSystem: TransitionSystem): Array<Decision>;
14
+ }
@@ -0,0 +1,45 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./Oracle", "./Decision", "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyType", "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyRelation"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RandomOracle = void 0;
13
+ const Oracle_1 = require("./Oracle");
14
+ const Decision_1 = require("./Decision");
15
+ const UniversalDependencyType_1 = require("nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyType");
16
+ const UniversalDependencyRelation_1 = require("nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyRelation");
17
+ class RandomOracle extends Oracle_1.Oracle {
18
+ constructor(model, windowSize) {
19
+ super(model, windowSize);
20
+ }
21
+ /**
22
+ * Makes a random decision based on a uniform distribution over possible actions.
23
+ * @param state The current state of the parser.
24
+ * @return A Decision object representing the randomly chosen action.
25
+ */
26
+ makeDecision(state) {
27
+ let command = Math.floor(Math.random() * 3);
28
+ let relation = Math.floor(Math.random() * 58);
29
+ switch (command) {
30
+ case 0:
31
+ return new Decision_1.Decision(Command.LEFTARC, UniversalDependencyRelation_1.UniversalDependencyRelation.universalDependencyTags[relation], 0);
32
+ case 1:
33
+ return new Decision_1.Decision(Command.RIGHTARC, UniversalDependencyRelation_1.UniversalDependencyRelation.universalDependencyTags[relation], 0);
34
+ case 2:
35
+ return new Decision_1.Decision(Command.SHIFT, UniversalDependencyType_1.UniversalDependencyType.DEP, 0);
36
+ }
37
+ return null;
38
+ }
39
+ scoreDecisions(state, transitionSystem) {
40
+ return null;
41
+ }
42
+ }
43
+ exports.RandomOracle = RandomOracle;
44
+ });
45
+ //# sourceMappingURL=RandomOracle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RandomOracle.js","sourceRoot":"","sources":["../source/Parser/TransitionBasedParser/RandomOracle.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,qCAAgC;IAEhC,yCAAoC;IAEpC,gHAA2G;IAC3G,wHAAmH;IAEnH,MAAa,YAAa,SAAQ,eAAM;QAEpC,YAAY,KAAY,EAAE,UAAkB;YACxC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;QAC5B,CAAC;QAED;;;;WAIG;QACI,YAAY,CAAC,KAAY;YAC5B,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;YAC3C,IAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;YAC7C,QAAQ,OAAO,EAAC;gBACZ,KAAK,CAAC;oBACF,OAAO,IAAI,mBAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,yDAA2B,CAAC,uBAAuB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;gBAC1G,KAAK,CAAC;oBACF,OAAO,IAAI,mBAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,yDAA2B,CAAC,uBAAuB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;gBAC3G,KAAK,CAAC;oBACF,OAAO,IAAI,mBAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,iDAAuB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;aACzE;YACD,OAAO,IAAI,CAAA;QACf,CAAC;QAES,cAAc,CAAC,KAAY,EAAE,gBAAkC;YACrE,OAAO,IAAI,CAAC;QAChB,CAAC;KAEJ;IA7BD,oCA6BC"}
@@ -0,0 +1,5 @@
1
+ import { ScoringOracle } from "./ScoringOracle";
2
+ import { State } from "./State";
3
+ export declare class RandomScoringOracle extends ScoringOracle {
4
+ score(state: State): number;
5
+ }
@@ -0,0 +1,21 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./ScoringOracle"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RandomScoringOracle = void 0;
13
+ const ScoringOracle_1 = require("./ScoringOracle");
14
+ class RandomScoringOracle extends ScoringOracle_1.ScoringOracle {
15
+ score(state) {
16
+ return Math.random();
17
+ }
18
+ }
19
+ exports.RandomScoringOracle = RandomScoringOracle;
20
+ });
21
+ //# sourceMappingURL=RandomScoringOracle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RandomScoringOracle.js","sourceRoot":"","sources":["../source/Parser/TransitionBasedParser/RandomScoringOracle.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,mDAA8C;IAG9C,MAAa,mBAAoB,SAAQ,6BAAa;QAElD,KAAK,CAAC,KAAY;YACd,OAAO,IAAI,CAAC,MAAM,EAAE,CAAA;QACxB,CAAC;KAEJ;IAND,kDAMC"}
@@ -0,0 +1,4 @@
1
+ import { State } from "./State";
2
+ export declare abstract class ScoringOracle {
3
+ abstract score(state: State): number;
4
+ }
@@ -0,0 +1,17 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ScoringOracle = void 0;
13
+ class ScoringOracle {
14
+ }
15
+ exports.ScoringOracle = ScoringOracle;
16
+ });
17
+ //# sourceMappingURL=ScoringOracle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScoringOracle.js","sourceRoot":"","sources":["../source/Parser/TransitionBasedParser/ScoringOracle.ts"],"names":[],"mappings":";;;;;;;;;;;;IAEA,MAAsB,aAAa;KAElC;IAFD,sCAEC"}
@@ -0,0 +1,14 @@
1
+ import { InstanceGenerator } from "./InstanceGenerator";
2
+ import { State } from "./State";
3
+ import { Instance } from "nlptoolkit-classification/dist/Instance/Instance";
4
+ export declare class SimpleInstanceGenerator extends InstanceGenerator {
5
+ constructor();
6
+ /**
7
+ * Generates an instance based on the state, window size, and command.
8
+ * @param state The current state of the parser, which includes the stack and word list.
9
+ * @param windowSize The size of the window used for feature extraction.
10
+ * @param command The command to be associated with the generated instance.
11
+ * @return The generated {@link Instance} object with attributes based on the state and command.
12
+ */
13
+ generate(state: State, windowSize: number, command: string): Instance;
14
+ }
@@ -0,0 +1,67 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./InstanceGenerator", "nlptoolkit-classification/dist/Instance/Instance", "nlptoolkit-classification/dist/Attribute/DiscreteIndexedAttribute", "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyTreeBankFeatures"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SimpleInstanceGenerator = void 0;
13
+ const InstanceGenerator_1 = require("./InstanceGenerator");
14
+ const Instance_1 = require("nlptoolkit-classification/dist/Instance/Instance");
15
+ const DiscreteIndexedAttribute_1 = require("nlptoolkit-classification/dist/Attribute/DiscreteIndexedAttribute");
16
+ const UniversalDependencyTreeBankFeatures_1 = require("nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyTreeBankFeatures");
17
+ class SimpleInstanceGenerator extends InstanceGenerator_1.InstanceGenerator {
18
+ constructor() {
19
+ super();
20
+ }
21
+ /**
22
+ * Generates an instance based on the state, window size, and command.
23
+ * @param state The current state of the parser, which includes the stack and word list.
24
+ * @param windowSize The size of the window used for feature extraction.
25
+ * @param command The command to be associated with the generated instance.
26
+ * @return The generated {@link Instance} object with attributes based on the state and command.
27
+ */
28
+ generate(state, windowSize, command) {
29
+ let instance = new Instance_1.Instance(command);
30
+ let attributes = new Array();
31
+ for (let i = 0; i < windowSize; i++) {
32
+ let word = state.getStackWord(i);
33
+ if (word == null) {
34
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("null", 0, 18));
35
+ this.addEmptyAttributes(attributes);
36
+ }
37
+ else {
38
+ if (word.getName() == "root") {
39
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("root", 0, 18));
40
+ this.addEmptyAttributes(attributes);
41
+ }
42
+ else {
43
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute(word.getUpos().toString(), UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.posIndex(word.getUpos().toString()) + 1, 18));
44
+ this.addFeatureAttributes(word, attributes);
45
+ }
46
+ }
47
+ }
48
+ for (let i = 0; i < windowSize; i++) {
49
+ let word = state.getWordListWord(i);
50
+ if (word != null) {
51
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute(word.getUpos().toString(), UniversalDependencyTreeBankFeatures_1.UniversalDependencyTreeBankFeatures.posIndex(word.getUpos().toString()) + 1, 18));
52
+ this.addFeatureAttributes(word, attributes);
53
+ }
54
+ else {
55
+ attributes.push(new DiscreteIndexedAttribute_1.DiscreteIndexedAttribute("root", 0, 18));
56
+ this.addEmptyAttributes(attributes);
57
+ }
58
+ }
59
+ for (let attribute of attributes) {
60
+ instance.addAttribute(attribute);
61
+ }
62
+ return instance;
63
+ }
64
+ }
65
+ exports.SimpleInstanceGenerator = SimpleInstanceGenerator;
66
+ });
67
+ //# sourceMappingURL=SimpleInstanceGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleInstanceGenerator.js","sourceRoot":"","sources":["../source/Parser/TransitionBasedParser/SimpleInstanceGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,2DAAsD;IAEtD,+EAA0E;IAC1E,gHAA2G;IAC3G,wIAEwF;IAGxF,MAAa,uBAAwB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K,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;gBACnC,IAAI,IAAI,IAAI,IAAI,EAAE;oBACd,UAAU,CAAC,IAAI,CAAC,IAAI,mDAAwB,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,yEAAmC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;oBACzJ,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;iBAC9C;qBAAM;oBACH,UAAU,CAAC,IAAI,CAAC,IAAI,mDAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;oBAC5D,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAA;iBACtC;aACJ;YACD,KAAK,IAAI,SAAS,IAAI,UAAU,EAAE;gBAC9B,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;aACnC;YACD,OAAO,QAAQ,CAAA;QACnB,CAAC;KAEJ;IA/CD,0DA+CC"}
@@ -0,0 +1,10 @@
1
+ import { UniversalDependencyTreeBankWord } from "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyTreeBankWord";
2
+ import { UniversalDependencyRelation } from "nlptoolkit-dependencyparser/dist/Universal/UniversalDependencyRelation";
3
+ export declare class StackRelation {
4
+ private readonly word;
5
+ private readonly relation;
6
+ constructor(word: UniversalDependencyTreeBankWord, relation: UniversalDependencyRelation);
7
+ clone(): StackRelation;
8
+ getWord(): UniversalDependencyTreeBankWord;
9
+ getRelation(): UniversalDependencyRelation;
10
+ }