Commit
•
87b8221
1
Parent(s):
a3be017
Upload summarize.py
Browse files- summarize.py +1 -4
summarize.py
CHANGED
@@ -36,8 +36,6 @@ part_11 = pages[41].page_content + \
|
|
36 |
pages[42].page_content + pages[43].page_content
|
37 |
|
38 |
# Fucntion to select different parts
|
39 |
-
|
40 |
-
|
41 |
def extract_part(part):
|
42 |
pattern = r"PART .*?(?=PART )"
|
43 |
match = re.search(pattern, part, flags=re.DOTALL)
|
@@ -146,7 +144,6 @@ def split_text_into_chunks(text, chunk_size):
|
|
146 |
|
147 |
# Preprocessing
|
148 |
|
149 |
-
|
150 |
def preprocess(country, section):
|
151 |
if country == "Kenya":
|
152 |
if section == None:
|
@@ -181,6 +178,7 @@ llm = ChatOpenAI(temperature=0, openai_api_key=openai.api_key,
|
|
181 |
# Prompt template
|
182 |
template = """
|
183 |
The text delimited by triple backquotes is an exerpt from the Data protection act of {country}
|
|
|
184 |
Write a concise summary of the following text delimited by triple backquotes.
|
185 |
Return your response in paragraph which covers the key points of the text.
|
186 |
```{text}```
|
@@ -193,7 +191,6 @@ llm_chain = LLMChain(prompt=prompt, llm=llm)
|
|
193 |
|
194 |
# function to summarize
|
195 |
|
196 |
-
|
197 |
def summarize(country, section):
|
198 |
|
199 |
Text = preprocess(country, section)
|
|
|
36 |
pages[42].page_content + pages[43].page_content
|
37 |
|
38 |
# Fucntion to select different parts
|
|
|
|
|
39 |
def extract_part(part):
|
40 |
pattern = r"PART .*?(?=PART )"
|
41 |
match = re.search(pattern, part, flags=re.DOTALL)
|
|
|
144 |
|
145 |
# Preprocessing
|
146 |
|
|
|
147 |
def preprocess(country, section):
|
148 |
if country == "Kenya":
|
149 |
if section == None:
|
|
|
178 |
# Prompt template
|
179 |
template = """
|
180 |
The text delimited by triple backquotes is an exerpt from the Data protection act of {country}
|
181 |
+
As an experienced legal analyst,
|
182 |
Write a concise summary of the following text delimited by triple backquotes.
|
183 |
Return your response in paragraph which covers the key points of the text.
|
184 |
```{text}```
|
|
|
191 |
|
192 |
# function to summarize
|
193 |
|
|
|
194 |
def summarize(country, section):
|
195 |
|
196 |
Text = preprocess(country, section)
|