Newer
Older
using System.Collections;
using System.Collections.Generic;
[Serializable]
public class Declaration
{
public string name;
public string isProof;
public string value;
}
[Serializable]
public class Scroll
{
public string problemTheory;
public string solutionTheory;
public string label;
public string description;
public Declaration[] declarations;
//public string output;
public static Scroll generateFromJson(string json) {
return JsonUtility.FromJson<Scroll>(json);
}
public string toJson() {
return JsonUtility.ToJson(this);
}
}
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
*/
public class Scroll : LightScroll
{
public string label;
public string description;
public List<ScrollFact> requiredFacts;
public static List<Scroll> FromJSON(string json)
{
List<Scroll> scrolls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scroll>>(json);
return scrolls;
}
public static string ToJSON(FilledScroll scroll)
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(scroll);
return json;
}
// id of fact, positions in Description
public static List<KeyValuePair<int,int>>[] FactOccurences;
public static void InitDynamicScroll(int n)
{
FactOccurences = new List<KeyValuePair<int, int>>[n];
}
//also collects occurences to be changed later
public static string ParseString(int stringId, string raw, List<ScrollFact> scrollFacts)
{
int i = 0;
while(true)
{
char[] rawChars = raw.ToCharArray();
i = Array.FindIndex(rawChars,i, c => c == '$');
if (i == -1) break;
// Debug.Log(i);
//id of Fact, specified after the $
int toChange = (int) Char.GetNumericValue(raw[i + 1]);
//label of this Fact
string label = scrollFacts[toChange].label;
raw = raw.Remove(i,2);
raw = raw.Insert(i,label);
if(FactOccurences[toChange] == null)
{
FactOccurences[toChange] = new List<KeyValuePair<int, int>>();
}
//if (toChange >= 0) Debug.Log(stringId);
FactOccurences[toChange].Add(new KeyValuePair<int, int>(stringId,i));
}
return raw;
}
/*
public class ScrollList
{
public List<Scroll> scrolls;
}*/
public class ScrollAssignment
{
public KeyValuePair<string, JSONManager.MMTTerm> assignment;
}
public class FilledScroll
{
LightScroll scroll;
List<ScrollAssignment> assignments;
public FilledScroll(LightScroll scroll, List<ScrollAssignment> assignments)
{
this.scroll = scroll;
this.assignments = assignments;
}
}
public class ScrollFact
{
public string uri;
public string label;
public FactBody tp;
public JSONManager.MMTTerm df;
}
public class FactBody
{
public JSONManager.MMTTerm original;
public JSONManager.MMTTerm simplified;
}
}
public class LightScroll
{
public string problemTheory;
public string solutionTheory;
}