-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSentence.d
More file actions
39 lines (30 loc) · 1023 Bytes
/
Copy pathSentence.d
File metadata and controls
39 lines (30 loc) · 1023 Bytes
1
2
3
4
5
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
39
module Sentence;
import std.conv : to;
import TruthValue : TruthValue;
import Stamp : Stamp;
import Terms : Term;
import TermTools;
shared class Sentence {
shared TruthValue truth; // can be null if question
shared Term term;
shared Stamp stamp;
public immutable char punctation;
public final shared this(char punctation, shared Term term, shared TruthValue truth, shared Stamp stamp) {
this.punctation = punctation;
this.term = term;
this.truth = truth;
this.stamp = stamp;
}
}
bool isQuestion(shared Sentence sentence) { return sentence.punctation == '?'; }
bool isJudgment(shared Sentence sentence) { return sentence.punctation == '.'; }
string convToStr(shared Sentence sentence) {
string str = convToStrRec(sentence.term) ~ sentence.punctation;
if (sentence.truth !is null) {
str ~= " %" ~ to!string(sentence.truth.freq) ~ ";" ~ to!string(sentence.truth.conf) ~ "%";
}
if (!sentence.stamp.occurrenceTime.isNull) {
str ~= " T="~to!string(sentence.stamp.occurrenceTime);
}
return str;
}