Dmitry Kirsanov commited on
Commit
9334bee
·
1 Parent(s): 38e5538

fix list management

Browse files
Files changed (1) hide show
  1. understand.py +10 -9
understand.py CHANGED
@@ -45,10 +45,11 @@ Give a one-paragraph summary of the document's content. Write just one paragraph
45
  <document>{self.values.get("FAD")}</document>"""))
46
 
47
 
48
- def parse_lists(self, ret, what, whatlist):
49
 
50
  lines = ret.splitlines()
51
  inlist = False
 
52
 
53
  for line in lines:
54
  line = line.strip()
@@ -65,9 +66,9 @@ Give a one-paragraph summary of the document's content. Write just one paragraph
65
  else:
66
  item = line
67
  print(f"---item: {item}")
68
- whatlist.append(item)
69
 
70
- print(f"===Parsed list {what}: {whatlist}")
71
 
72
 
73
  def query_concepts(self):
@@ -104,8 +105,8 @@ Here's the document:
104
 
105
  <document>{self.values.get("FAD")}</document>""")
106
 
107
- self.parse_lists(ret, "concepts", attempt["concepts"])
108
- self.parse_lists(ret, "actors", attempt["actors"])
109
 
110
  #reconcile two lists
111
  for what in [
@@ -128,20 +129,20 @@ Compare the two lists:
128
  - If you see some {what['singular']} in the document that both lists missed, add it.
129
 
130
  First list of {what['plural']}:
131
- {newline.join(["- " + x for x in two_attempts[0]["concepts"]])}
132
 
133
  Second list of {what['plural']}:
134
- {newline.join(["- " + x for x in two_attempts[1]["concepts"]])}
135
 
136
  Output the line "{what['plural'].upper()}:" followed by your combined list of {what['plural']}, one per line.
137
 
138
  Here's the document:
139
 
140
  <document>{self.values.get("FAD")}</document>""")
141
- self.parse_lists(ret, what['plural'], two_attempts[0][what['plural']])
142
  print(f"===Reconciled {what['plural']}: {two_attempts[0][what['plural']]}")
143
 
144
-
145
  self.values.put("concepts", two_attempts[0]["concepts"])
146
  self.values.put("actors", two_attempts[0]["actors"])
147
 
 
45
  <document>{self.values.get("FAD")}</document>"""))
46
 
47
 
48
+ def parse_lists(self, ret, what):
49
 
50
  lines = ret.splitlines()
51
  inlist = False
52
+ retlist = []
53
 
54
  for line in lines:
55
  line = line.strip()
 
66
  else:
67
  item = line
68
  print(f"---item: {item}")
69
+ retlist.append(item)
70
 
71
+ print(f"===Parsed list {what}: {retlist}")
72
 
73
 
74
  def query_concepts(self):
 
105
 
106
  <document>{self.values.get("FAD")}</document>""")
107
 
108
+ attempt["concepts"] = self.parse_lists(ret, "concepts")
109
+ attempt["actors"] = self.parse_lists(ret, "actors")
110
 
111
  #reconcile two lists
112
  for what in [
 
129
  - If you see some {what['singular']} in the document that both lists missed, add it.
130
 
131
  First list of {what['plural']}:
132
+ {newline.join(["- " + x for x in two_attempts[0][what['plural']]])}
133
 
134
  Second list of {what['plural']}:
135
+ {newline.join(["- " + x for x in two_attempts[1][what['plural']]])}
136
 
137
  Output the line "{what['plural'].upper()}:" followed by your combined list of {what['plural']}, one per line.
138
 
139
  Here's the document:
140
 
141
  <document>{self.values.get("FAD")}</document>""")
142
+ two_attempts[0][what['plural']] = self.parse_lists(ret, what['plural'])
143
  print(f"===Reconciled {what['plural']}: {two_attempts[0][what['plural']]}")
144
 
145
+ # finally store in the values
146
  self.values.put("concepts", two_attempts[0]["concepts"])
147
  self.values.put("actors", two_attempts[0]["actors"])
148