Fenris Wolf

Fenris Wolf commited on 2017-04-17 12:01:43
Zeige 8 geänderte Dateien mit 157 Einfügungen und 14 Löschungen.

... ...
@@ -26,8 +26,16 @@
26 26
 		</mkdir>
27 27
 		<concat destfile="build/model.js">
28 28
 			<filelist dir=".">
29
+				<file name="source/model/concept.js">
30
+				</file>
31
+				<file name="source/model/wordfragment.js">
32
+				</file>
29 33
 				<file name="source/model/word.js">
30 34
 				</file>
35
+				<file name="source/model/translation.js">
36
+				</file>
37
+				<file name="source/model/transition.js">
38
+				</file>
31 39
 			</filelist>
32 40
 		</concat>
33 41
 	</target>
... ...
@@ -0,0 +1,24 @@
1
+
2
+/**
3
+ * @author fenris
4
+ */
5
+class Concept
6
+{
7
+	
8
+	/**
9
+	 * @param {string} type the type of the concept; can be 'verb','noun','attribute','other'
10
+	 * @param {string} description a text describing the concept; default: null
11
+	 * @param {Array<string>} tags a list of strings with which the concept is tagged; default: []
12
+	 */
13
+	constructor(type, description, tags)
14
+	{
15
+		if (description == undefined) description = null;
16
+		if (tags == undefined) tags = [];
17
+		
18
+		this.type = type;
19
+		this.description = description;
20
+		this.tags = tags;
21
+	}
22
+	
23
+}
24
+
... ...
@@ -0,0 +1,32 @@
1
+
2
+/**
3
+ * @author fenris
4
+ */
5
+class Transition
6
+{
7
+	
8
+	/**
9
+	 */
10
+	constructor(from, to)
11
+	{
12
+		this.from = from;
13
+		this.to = to;
14
+	}
15
+	
16
+	
17
+	/**
18
+	 */
19
+	use(word)
20
+	{
21
+		if (word.language == this.from.language)
22
+		{
23
+			
24
+		}
25
+		else
26
+		{
27
+			throw (new Error("not applicable"));
28
+		}
29
+	}
30
+	
31
+}
32
+
... ...
@@ -0,0 +1,20 @@
1
+
2
+/**
3
+ * @author fenris
4
+ */
5
+class Translation
6
+{
7
+	
8
+	/**
9
+	 */
10
+	constructor(concept, word, score)
11
+	{
12
+		if (score == undefined) score = 1.0;
13
+		
14
+		this.concept = concept;
15
+		this.word = word;
16
+		this.score = score;
17
+	}
18
+	
19
+}
20
+
... ...
@@ -2,22 +2,15 @@
2 2
 /**
3 3
  * @author fenris
4 4
  */
5
-class Word
5
+class Word extends Wordfragment
6 6
 {
7
+	
8
+	/**
9
+	 */
7 10
 	constructor(language, representation, pronunciation)
8 11
 	{
9
-		this.language = language;
10
-		this.representation = representation;
11
-		this.pronunciation = pronunciation
12
+		super(language, representation, pronunciation);
12 13
 	}
13 14
 	
14
-	toString()
15
-	{
16
-		let parts = [];
17
-		if (this.language != null) parts.push("[" + this.language + "]");
18
-		if (this.representation != null) parts.push("\"" + this.representation + "\"");
19
-		if (this.pronunciation != null) parts.push("(" + this.pronunciation + ")");
20
-		return parts.join(" ");
21
-	}
22 15
 }
23 16
 
... ...
@@ -0,0 +1,30 @@
1
+
2
+/**
3
+ * @author fenris
4
+ */
5
+class Wordfragment
6
+{
7
+	
8
+	/**
9
+	 */
10
+	constructor(language, representation, pronunciation)
11
+	{
12
+		this.language = language;
13
+		this.representation = representation;
14
+		this.pronunciation = pronunciation;
15
+	}
16
+	
17
+	
18
+	/**
19
+	 */
20
+	toString()
21
+	{
22
+		let parts = [];
23
+		if (this.language != null) parts.push("[" + this.language + "]");
24
+		if (this.representation != null) parts.push("\"" + this.representation + "\"");
25
+		if (this.pronunciation != null) parts.push("(" + this.pronunciation + ")");
26
+		return parts.join(" ");
27
+	}
28
+	
29
+}
30
+
... ...
@@ -4,10 +4,27 @@
4 4
  */
5 5
 function main()
6 6
 {
7
+	let concepts = [
8
+		new Concept("noun", "bread; food made of flour", ["food"]),
9
+	];
7 10
 	let words = [
8
-		new Word("de", "Brot", "/bʁoːt/"),
9 11
 		new Word("pg", "braudą", "/ˈbrɑu̯.ðɑ̃/"),
10
-	]
12
+		new Word("de", "Brot", "/bʁoːt/"),
13
+		new Word("nb", "brød", "/brøː/"),
14
+	];
15
+	let translations = [
16
+		new Translations(concept[0], words[0]),
17
+		new Translations(concept[0], words[1]),
18
+	];
19
+	let wordfragments = [
20
+		new Wordfragment("pg", "au", "/ɑu̯/"),
21
+		new Wordfragment("de", "o", "/oː/"),
22
+		new Wordfragment("nb", "ø", "/øː/"),
23
+	];
24
+	let transitions = [
25
+		new Transition(wordfragments[0], wordfragments[1]),
26
+		new Transition(wordfragments[0], wordfragments[2]),
27
+	];
11 28
 	
12 29
 	words.forEach(word => console.info(word.toString()));
13 30
 }
... ...
@@ -0,0 +1,19 @@
1
+
2
+/**
3
+ * @author fenris
4
+ */
5
+class SQLWrapper
6
+{
7
+	
8
+	/**
9
+	 * @param {any} core the core value
10
+	 * @param {Object} meta an object containing meta information like the database-id
11
+	 */
12
+	constructor(core, meta)
13
+	{
14
+		this.core = core;
15
+		this.meta = meta;
16
+	}
17
+	
18
+}
19
+
0 20