-
Notifications
You must be signed in to change notification settings - Fork 0
/
pseudocode.txt
71 lines (64 loc) · 1.41 KB
/
pseudocode.txt
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
TODO:
-[ ] mainMenu:
-[ ] updateTextFn
-[ ] askQuestionFn
-[ ] explinationFn
-[x] determineFactoidType
-[ ] removeStopWords
-[ ] Split
-[ ] CalculateSimularity
-[ ] GetPerson
-[ ] GetLocation
-[ ] GetDateTime
-[ ] GetAmount
-[ ] printAnswerFn
Function determineFactoidType;
Var string firstWord, question, answerType;
Var boolean done;
//TODO add comments inline
BEGIN
// assuming that question is already input
i = 0;
done = false;
WHILE done == false DO
firstWord[i] = firstWord + question[i];
IF firstWord[i] != ' ' AND firstWord != "How" THEN
firstWord = firstWord + question[i];
ELSE
IF question[i] == ' ' AND firstWorld == "How" THEN
firstWord = firstWord + question[i];
i = i + 1;
firstWord = firstWord + question[i];
END IF;
END IF;
IF question[i] == ' ' THEN
done = true;
END IF;
i = i + 1;
END WHILE;
SWITCH (firstWord) DO
case "Who":
answerType = "getPerson";
Break;
case "When":
answerType = "getDateTime";
Break;
case "Where":
answerType = "getPlace";
Break;
case "How many":
answerType = "getAmount";
Break;
case "How much":
answerType = "getAmount";
Break;
default:
Write ("The question you have asked is invalid, please rephrase your question and ask again.");
badQuestion = badQuestion +1;
IF (badQuestion >= 3) THEN
explinationFn;
END IF;
Break;
END SWITCH;
return answerType;
END