nlptoolkit-morphologicalanalysis 1.0.18 → 1.0.19
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/dist/Corpus/DisambiguatedWord.js +26 -35
- package/dist/Corpus/DisambiguatedWord.js.map +1 -1
- package/dist/Corpus/DisambiguationCorpus.js +70 -47
- package/dist/Corpus/DisambiguationCorpus.js.map +1 -1
- package/dist/MorphologicalAnalysis/FiniteStateMachine.js +148 -158
- package/dist/MorphologicalAnalysis/FiniteStateMachine.js.map +1 -1
- package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js +1281 -1254
- package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js.map +1 -1
- package/dist/MorphologicalAnalysis/FsmParse.js +596 -603
- package/dist/MorphologicalAnalysis/FsmParse.js.map +1 -1
- package/dist/MorphologicalAnalysis/FsmParseList.js +263 -273
- package/dist/MorphologicalAnalysis/FsmParseList.js.map +1 -1
- package/dist/MorphologicalAnalysis/InflectionalGroup.js +152 -162
- package/dist/MorphologicalAnalysis/InflectionalGroup.js.map +1 -1
- package/dist/MorphologicalAnalysis/MetamorphicParse.js +120 -129
- package/dist/MorphologicalAnalysis/MetamorphicParse.js.map +1 -1
- package/dist/MorphologicalAnalysis/MorphologicalParse.js +1037 -1046
- package/dist/MorphologicalAnalysis/MorphologicalParse.js.map +1 -1
- package/dist/MorphologicalAnalysis/MorphologicalTag.js +530 -540
- package/dist/MorphologicalAnalysis/MorphologicalTag.js.map +1 -1
- package/dist/MorphologicalAnalysis/MorphotacticEngine.js +230 -240
- package/dist/MorphologicalAnalysis/MorphotacticEngine.js.map +1 -1
- package/dist/MorphologicalAnalysis/State.js +54 -60
- package/dist/MorphologicalAnalysis/State.js.map +1 -1
- package/dist/MorphologicalAnalysis/Transition.js +408 -418
- package/dist/MorphologicalAnalysis/Transition.js.map +1 -1
- package/dist/index.js +19 -25
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
- package/tsconfig.json +4 -3
- package/source/tsconfig.json +0 -13
|
@@ -1,38 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DisambiguatedWord = void 0;
|
|
4
|
+
const Word_1 = require("nlptoolkit-dictionary/dist/Dictionary/Word");
|
|
5
|
+
class DisambiguatedWord extends Word_1.Word {
|
|
6
|
+
parse;
|
|
7
|
+
/**
|
|
8
|
+
* The constructor of {@link DisambiguatedWord} class which takes a {@link String} and a {@link MorphologicalParse}
|
|
9
|
+
* as inputs. It creates a new {@link MorphologicalParse} with given MorphologicalParse. It generates a new instance with
|
|
10
|
+
* given {@link String}.
|
|
11
|
+
*
|
|
12
|
+
* @param name Instances that will be a DisambiguatedWord.
|
|
13
|
+
* @param parse {@link MorphologicalParse} of the {@link DisambiguatedWord}.
|
|
14
|
+
*/
|
|
15
|
+
constructor(name, parse) {
|
|
16
|
+
super(name);
|
|
17
|
+
this.parse = parse;
|
|
5
18
|
}
|
|
6
|
-
|
|
7
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Accessor for the {@link MorphologicalParse}.
|
|
21
|
+
*
|
|
22
|
+
* @return MorphologicalParse.
|
|
23
|
+
*/
|
|
24
|
+
getParse() {
|
|
25
|
+
return this.parse;
|
|
8
26
|
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DisambiguatedWord = void 0;
|
|
13
|
-
const Word_1 = require("nlptoolkit-dictionary/dist/Dictionary/Word");
|
|
14
|
-
class DisambiguatedWord extends Word_1.Word {
|
|
15
|
-
/**
|
|
16
|
-
* The constructor of {@link DisambiguatedWord} class which takes a {@link String} and a {@link MorphologicalParse}
|
|
17
|
-
* as inputs. It creates a new {@link MorphologicalParse} with given MorphologicalParse. It generates a new instance with
|
|
18
|
-
* given {@link String}.
|
|
19
|
-
*
|
|
20
|
-
* @param name Instances that will be a DisambiguatedWord.
|
|
21
|
-
* @param parse {@link MorphologicalParse} of the {@link DisambiguatedWord}.
|
|
22
|
-
*/
|
|
23
|
-
constructor(name, parse) {
|
|
24
|
-
super(name);
|
|
25
|
-
this.parse = parse;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Accessor for the {@link MorphologicalParse}.
|
|
29
|
-
*
|
|
30
|
-
* @return MorphologicalParse.
|
|
31
|
-
*/
|
|
32
|
-
getParse() {
|
|
33
|
-
return this.parse;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.DisambiguatedWord = DisambiguatedWord;
|
|
37
|
-
});
|
|
27
|
+
}
|
|
28
|
+
exports.DisambiguatedWord = DisambiguatedWord;
|
|
38
29
|
//# sourceMappingURL=DisambiguatedWord.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisambiguatedWord.js","sourceRoot":"","sources":["../../source/Corpus/DisambiguatedWord.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DisambiguatedWord.js","sourceRoot":"","sources":["../../source/Corpus/DisambiguatedWord.ts"],"names":[],"mappings":";;;AAAA,qEAAgE;AAGhE,MAAa,iBAAkB,SAAQ,WAAI;IAE/B,KAAK,CAAoB;IAEjC;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,KAAyB;QAC/C,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,CAAC;CACJ;AAzBD,8CAyBC"}
|
|
@@ -1,53 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DisambiguationCorpus = void 0;
|
|
37
|
+
const Corpus_1 = require("nlptoolkit-corpus/dist/Corpus");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const DisambiguatedWord_1 = require("./DisambiguatedWord");
|
|
40
|
+
const MorphologicalParse_1 = require("../MorphologicalAnalysis/MorphologicalParse");
|
|
41
|
+
const Sentence_1 = require("nlptoolkit-corpus/dist/Sentence");
|
|
42
|
+
class DisambiguationCorpus extends Corpus_1.Corpus {
|
|
43
|
+
/**
|
|
44
|
+
* Constructor which takes a file name {@link String} as an input and reads the file line by line. It takes each word of the line,
|
|
45
|
+
* and creates a new {@link DisambiguatedWord} with current word and its {@link MorphologicalParse}. It also creates a new {@link Sentence}
|
|
46
|
+
* when a new sentence starts, and adds each word to this sentence till the end of that sentence.
|
|
47
|
+
*
|
|
48
|
+
* @param fileName File which will be read and parsed.
|
|
49
|
+
*/
|
|
50
|
+
constructor(fileName) {
|
|
51
|
+
super();
|
|
52
|
+
if (fileName != undefined) {
|
|
53
|
+
let newSentence = undefined;
|
|
54
|
+
let data = fs.readFileSync(fileName, 'utf8');
|
|
55
|
+
let lines = data.split("\n");
|
|
56
|
+
for (let line of lines) {
|
|
57
|
+
let word = line.substring(0, line.indexOf("\t"));
|
|
58
|
+
let parse = line.substring(line.indexOf("\t") + 1);
|
|
59
|
+
if (word != "" && parse != "") {
|
|
60
|
+
let newWord = new DisambiguatedWord_1.DisambiguatedWord(word, new MorphologicalParse_1.MorphologicalParse(parse));
|
|
61
|
+
if (word == "<S>") {
|
|
62
|
+
newSentence = new Sentence_1.Sentence();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (word == "</S>") {
|
|
66
|
+
this.addSentence(newSentence);
|
|
39
67
|
}
|
|
40
68
|
else {
|
|
41
|
-
if (word == "</
|
|
42
|
-
this.addSentence(newSentence);
|
|
69
|
+
if (word == "<DOC>" || word == "</DOC>" || word == "<TITLE>" || word == "</TITLE>") {
|
|
43
70
|
}
|
|
44
71
|
else {
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
else {
|
|
48
|
-
if (newSentence != null) {
|
|
49
|
-
newSentence.addWord(newWord);
|
|
50
|
-
}
|
|
72
|
+
if (newSentence != null) {
|
|
73
|
+
newSentence.addWord(newWord);
|
|
51
74
|
}
|
|
52
75
|
}
|
|
53
76
|
}
|
|
@@ -56,6 +79,6 @@
|
|
|
56
79
|
}
|
|
57
80
|
}
|
|
58
81
|
}
|
|
59
|
-
|
|
60
|
-
|
|
82
|
+
}
|
|
83
|
+
exports.DisambiguationCorpus = DisambiguationCorpus;
|
|
61
84
|
//# sourceMappingURL=DisambiguationCorpus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisambiguationCorpus.js","sourceRoot":"","sources":["../../source/Corpus/DisambiguationCorpus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DisambiguationCorpus.js","sourceRoot":"","sources":["../../source/Corpus/DisambiguationCorpus.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAqD;AACrD,uCAAyB;AACzB,2DAAsD;AACtD,oFAA+E;AAC/E,8DAAyD;AAEzD,MAAa,oBAAqB,SAAQ,eAAM;IAE5C;;;;;;OAMG;IACH,YAAY,QAAiB;QACzB,KAAK,EAAE,CAAC;QACR,IAAI,QAAQ,IAAI,SAAS,EAAC,CAAC;YACvB,IAAI,WAAW,GAAG,SAAS,CAAC;YAC5B,IAAI,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAC5C,IAAI,KAAK,GAA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|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
while (stateNode != undefined) {
|
|
42
|
-
if (stateNode.hasAttributes()) {
|
|
43
|
-
let stateName = stateNode.getAttributeValue("name");
|
|
44
|
-
let startState = stateNode.getAttributeValue("start");
|
|
45
|
-
let endState = stateNode.getAttributeValue("end");
|
|
46
|
-
let state;
|
|
47
|
-
if (startState == "yes") {
|
|
48
|
-
let originalPos = stateNode.getAttributeValue("originalpos");
|
|
49
|
-
state = new State_1.State(stateName, true, endState == "yes", originalPos);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
state = new State_1.State(stateName, false, endState == "yes");
|
|
53
|
-
}
|
|
54
|
-
this.states.push(state);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiniteStateMachine = void 0;
|
|
4
|
+
const State_1 = require("./State");
|
|
5
|
+
const Transition_1 = require("./Transition");
|
|
6
|
+
const XmlDocument_1 = require("nlptoolkit-xmlparser/dist/XmlDocument");
|
|
7
|
+
class FiniteStateMachine {
|
|
8
|
+
states = new Array();
|
|
9
|
+
transitions = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Constructor reads the finite state machine in the given input file. It has a NodeList which holds the states
|
|
12
|
+
* of the nodes and there are 4 different type of nodes; stateNode, root Node, transitionNode and withNode.
|
|
13
|
+
* Also there are two states; state that a node currently in and state that a node will be in.
|
|
14
|
+
* <p>
|
|
15
|
+
* DOMParser is used to parse the given file. Firstly it gets the document to parse, then gets its elements by the
|
|
16
|
+
* tag names. For instance, it gets states by the tag name 'state' and puts them into an ArrayList called stateList.
|
|
17
|
+
* Secondly, it traverses this stateList and gets each Node's attributes. There are three attributes; name, start,
|
|
18
|
+
* and end which will be named as states. If a node is in a startState it is tagged as 'yes', otherwise 'no'.
|
|
19
|
+
* Also, if a node is in a startState, additional attribute will be fetched; originalPos that represents its original
|
|
20
|
+
* part of speech.
|
|
21
|
+
* <p>
|
|
22
|
+
* At the last step, by starting rootNode's first child, it gets all the transitionNodes and next states called toState,
|
|
23
|
+
* then continue with the nextSiblings. Also, if there is no possible toState, it prints this case and the causative states.
|
|
24
|
+
*
|
|
25
|
+
* @param fileName the resource file to read the finite state machine. Only files in resources folder are supported.
|
|
26
|
+
*/
|
|
27
|
+
constructor(fileName = "turkish_finite_state_machine.xml") {
|
|
28
|
+
let xmlDocument = new XmlDocument_1.XmlDocument(fileName);
|
|
29
|
+
xmlDocument.parse();
|
|
30
|
+
let stateListNode = xmlDocument.getFirstChild();
|
|
31
|
+
let stateNode = stateListNode.getFirstChild();
|
|
32
|
+
while (stateNode != undefined) {
|
|
33
|
+
if (stateNode.hasAttributes()) {
|
|
34
|
+
let stateName = stateNode.getAttributeValue("name");
|
|
35
|
+
let startState = stateNode.getAttributeValue("start");
|
|
36
|
+
let endState = stateNode.getAttributeValue("end");
|
|
37
|
+
let state;
|
|
38
|
+
if (startState == "yes") {
|
|
39
|
+
let originalPos = stateNode.getAttributeValue("originalpos");
|
|
40
|
+
state = new State_1.State(stateName, true, endState == "yes", originalPos);
|
|
55
41
|
}
|
|
56
|
-
|
|
42
|
+
else {
|
|
43
|
+
state = new State_1.State(stateName, false, endState == "yes");
|
|
44
|
+
}
|
|
45
|
+
this.states.push(state);
|
|
57
46
|
}
|
|
58
|
-
stateNode =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.addTransition(state, toState, withNode.getPcData(), withName, rootToPos);
|
|
86
|
-
}
|
|
47
|
+
stateNode = stateNode.getNextSibling();
|
|
48
|
+
}
|
|
49
|
+
stateNode = stateListNode.getFirstChild();
|
|
50
|
+
while (stateNode != undefined) {
|
|
51
|
+
if (stateNode.hasAttributes()) {
|
|
52
|
+
let stateName = stateNode.getAttributeValue("name");
|
|
53
|
+
let state = this.getState(stateName);
|
|
54
|
+
let transitionNode = stateNode.getFirstChild();
|
|
55
|
+
while (transitionNode != undefined) {
|
|
56
|
+
if (transitionNode.hasAttributes()) {
|
|
57
|
+
let toStateName = transitionNode.getAttributeValue("name");
|
|
58
|
+
let toState = this.getState(toStateName);
|
|
59
|
+
let withName = transitionNode.getAttributeValue("transitionname");
|
|
60
|
+
let rootToPos = transitionNode.getAttributeValue("topos");
|
|
61
|
+
let withNode = transitionNode.getFirstChild();
|
|
62
|
+
while (withNode != undefined) {
|
|
63
|
+
let toPos;
|
|
64
|
+
if (withNode.hasAttributes()) {
|
|
65
|
+
withName = withNode.getAttributeValue("name");
|
|
66
|
+
toPos = withNode.getAttributeValue("topos");
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
toPos = "";
|
|
70
|
+
}
|
|
71
|
+
if (toPos == "") {
|
|
72
|
+
if (rootToPos == "") {
|
|
73
|
+
this.addTransition(state, toState, withNode.getPcData(), withName);
|
|
87
74
|
}
|
|
88
75
|
else {
|
|
89
|
-
this.addTransition(state, toState, withNode.getPcData(), withName,
|
|
76
|
+
this.addTransition(state, toState, withNode.getPcData(), withName, rootToPos);
|
|
90
77
|
}
|
|
91
|
-
withNode = withNode.getNextSibling();
|
|
92
78
|
}
|
|
79
|
+
else {
|
|
80
|
+
this.addTransition(state, toState, withNode.getPcData(), withName, toPos);
|
|
81
|
+
}
|
|
82
|
+
withNode = withNode.getNextSibling();
|
|
93
83
|
}
|
|
94
|
-
transitionNode = transitionNode.getNextSibling();
|
|
95
84
|
}
|
|
85
|
+
transitionNode = transitionNode.getNextSibling();
|
|
96
86
|
}
|
|
97
|
-
stateNode = stateNode.getNextSibling();
|
|
98
87
|
}
|
|
88
|
+
stateNode = stateNode.getNextSibling();
|
|
99
89
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The isValidTransition loops through states ArrayList and checks transitions between states. If the actual transition
|
|
93
|
+
* equals to the given transition input, method returns true otherwise returns false.
|
|
94
|
+
*
|
|
95
|
+
* @param transition is used to compare with the actual transition of a state.
|
|
96
|
+
* @return true when the actual transition equals to the transition input, false otherwise.
|
|
97
|
+
*/
|
|
98
|
+
isValidTransition(transition) {
|
|
99
|
+
for (let state of this.transitions.keys()) {
|
|
100
|
+
for (let transition1 of this.transitions.get(state)) {
|
|
101
|
+
if (transition1.toString() != undefined && transition1.toString() == transition) {
|
|
102
|
+
return true;
|
|
113
103
|
}
|
|
114
104
|
}
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* the getStates method returns the states in the FiniteStateMachine.
|
|
119
|
-
* @return StateList.
|
|
120
|
-
*/
|
|
121
|
-
getStates() {
|
|
122
|
-
return this.states;
|
|
123
105
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* the getStates method returns the states in the FiniteStateMachine.
|
|
110
|
+
* @return StateList.
|
|
111
|
+
*/
|
|
112
|
+
getStates() {
|
|
113
|
+
return this.states;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The getState method is used to loop through the states {@link Array} and return the state whose name equal
|
|
117
|
+
* to the given input name.
|
|
118
|
+
*
|
|
119
|
+
* @param name is used to compare with the state's actual name.
|
|
120
|
+
* @return state if found any, null otherwise.
|
|
121
|
+
*/
|
|
122
|
+
getState(name) {
|
|
123
|
+
for (let state of this.states) {
|
|
124
|
+
if (state.getName() == name) {
|
|
125
|
+
return state;
|
|
136
126
|
}
|
|
137
|
-
return undefined;
|
|
138
127
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
transitionList = new Array();
|
|
157
|
-
}
|
|
158
|
-
transitionList.push(newTransition);
|
|
159
|
-
this.transitions.set(fromState, transitionList);
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Another addTransition method which takes additional argument; toPos and. It creates a new {@link Transition}
|
|
132
|
+
* with given input parameters and adds the transition to transitions {@link Array}.
|
|
133
|
+
*
|
|
134
|
+
* @param fromState State type input indicating the from state.
|
|
135
|
+
* @param toState State type input indicating the next state.
|
|
136
|
+
* @param _with String input indicating with what the transition will be made.
|
|
137
|
+
* @param withName String input.
|
|
138
|
+
* @param toPos String input.
|
|
139
|
+
*/
|
|
140
|
+
addTransition(fromState, toState, _with, withName, toPos) {
|
|
141
|
+
let newTransition = new Transition_1.Transition(_with, withName, toState, toPos);
|
|
142
|
+
let transitionList;
|
|
143
|
+
if (this.transitions.has(fromState)) {
|
|
144
|
+
transitionList = this.transitions.get(fromState);
|
|
160
145
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
146
|
+
else {
|
|
147
|
+
transitionList = new Array();
|
|
148
|
+
}
|
|
149
|
+
transitionList.push(newTransition);
|
|
150
|
+
this.transitions.set(fromState, transitionList);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The getTransitions method returns the transitions at the given state.
|
|
154
|
+
*
|
|
155
|
+
* @param state State input.
|
|
156
|
+
* @return transitions at given state.
|
|
157
|
+
*/
|
|
158
|
+
getTransitions(state) {
|
|
159
|
+
if (this.transitions.has(state)) {
|
|
160
|
+
return this.transitions.get(state);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return new Array();
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
|
-
|
|
177
|
-
|
|
166
|
+
}
|
|
167
|
+
exports.FiniteStateMachine = FiniteStateMachine;
|
|
178
168
|
//# sourceMappingURL=FiniteStateMachine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FiniteStateMachine.js","sourceRoot":"","sources":["../../source/MorphologicalAnalysis/FiniteStateMachine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FiniteStateMachine.js","sourceRoot":"","sources":["../../source/MorphologicalAnalysis/FiniteStateMachine.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAC9B,6CAAwC;AACxC,uEAAkE;AAElE,MAAa,kBAAkB;IAEnB,MAAM,GAAiB,IAAI,KAAK,EAAS,CAAA;IACzC,WAAW,GAAkC,IAAI,GAAG,EAA4B,CAAA;IAExF;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,WA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