Spaces:
Runtime error
Runtime error
Dmitry Kirsanov commited on
Commit ·
78b4826
1
Parent(s): 0a2597f
split
Browse files- understand.py +20 -0
understand.py
CHANGED
|
@@ -239,6 +239,24 @@ Output just the document with the audience markup sentence, but otherwise unchan
|
|
| 239 |
self.values.put("FAD with audience", annotated1)
|
| 240 |
self.values.put("FAD with audience, diff", diff)
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
def ingest(self, filename):
|
| 244 |
soup = parse.parse(filename)
|
|
@@ -255,6 +273,7 @@ Output just the document with the audience markup sentence, but otherwise unchan
|
|
| 255 |
self.query_concepts()
|
| 256 |
self.generalize_actors()
|
| 257 |
self.annotate_actors()
|
|
|
|
| 258 |
|
| 259 |
def get_understanding(self):
|
| 260 |
self.understand()
|
|
@@ -267,6 +286,7 @@ Output just the document with the audience markup sentence, but otherwise unchan
|
|
| 267 |
"=== Actors, generalized:\n"+newline.join(["- " + x for x in self.values.get("actors, generalized")]),
|
| 268 |
"=== Document annotated:\n"+self.values.get("FAD with audience"),
|
| 269 |
"=== Document annotated, diff of 2 attempts:\n"+self.values.get("FAD with audience, diff"),
|
|
|
|
| 270 |
)
|
| 271 |
|
| 272 |
|
|
|
|
| 239 |
self.values.put("FAD with audience", annotated1)
|
| 240 |
self.values.put("FAD with audience, diff", diff)
|
| 241 |
|
| 242 |
+
def split_document(self):
|
| 243 |
+
ret = self.query(
|
| 244 |
+
f"""Below is a document inside <document></document>. It is a {self.values.get("document type")}.
|
| 245 |
+
|
| 246 |
+
Summary of the document:
|
| 247 |
+
{self.values.get("summary")}
|
| 248 |
+
|
| 249 |
+
Read the entire document carefully. Remember everything you know about the concepts it touches.
|
| 250 |
+
|
| 251 |
+
Each sentence of the document is marked up with an audience attribute that indicates who is the intended audience of this sentence. Here's the complete list of audiences:
|
| 252 |
+
|
| 253 |
+
{newline.join(["- " + x for x in self.values.get("actors, generalized")])}
|
| 254 |
+
|
| 255 |
+
Your goal is to select all sentences that include "{self.values.get("actors, generalized")[0]}" as the audience and rewrite them into a connected structured text that makes sense for this audience. You can rearrange the selected sentences, add other sentences from the original document, or write your own connecting sentences. Output the result as plain text, omitting all <sentence> tags.
|
| 256 |
+
|
| 257 |
+
<document>{self.values.get("FAD with audience")}</document>""")
|
| 258 |
+
self.values.put(f"""FAD for {self.values.get("actors, generalized")[0]}""", ret)
|
| 259 |
+
|
| 260 |
|
| 261 |
def ingest(self, filename):
|
| 262 |
soup = parse.parse(filename)
|
|
|
|
| 273 |
self.query_concepts()
|
| 274 |
self.generalize_actors()
|
| 275 |
self.annotate_actors()
|
| 276 |
+
self.split_document()
|
| 277 |
|
| 278 |
def get_understanding(self):
|
| 279 |
self.understand()
|
|
|
|
| 286 |
"=== Actors, generalized:\n"+newline.join(["- " + x for x in self.values.get("actors, generalized")]),
|
| 287 |
"=== Document annotated:\n"+self.values.get("FAD with audience"),
|
| 288 |
"=== Document annotated, diff of 2 attempts:\n"+self.values.get("FAD with audience, diff"),
|
| 289 |
+
f"=== Document rewritten for {self.values.get('actors, generalized')[0]}:\n"+self.values.get("""FAD for {self.values.get("actors, generalized")[0]}"""),
|
| 290 |
)
|
| 291 |
|
| 292 |
|