Spaces:
Sleeping
Sleeping
GuysRGithub
commited on
Commit
•
8f810ad
1
Parent(s):
a4cc6d9
Post process output
Browse files
app.py
CHANGED
@@ -130,11 +130,11 @@ def chat():
|
|
130 |
return {"message": response}
|
131 |
|
132 |
def post_process(output):
|
133 |
-
|
134 |
lines = output.split("\n")
|
135 |
for line in lines:
|
136 |
for word in word_remove_sentence:
|
137 |
-
if word
|
138 |
lines.remove(line)
|
139 |
break
|
140 |
|
@@ -142,8 +142,12 @@ def post_process(output):
|
|
142 |
for item in map_words.keys():
|
143 |
output = re.sub(item, map_words[item], output, re.I)
|
144 |
|
145 |
-
return output
|
146 |
-
|
|
|
|
|
|
|
|
|
147 |
|
148 |
|
149 |
subprocess.Popen(["autossh", "-M", "0", "-o", "StrictHostKeyChecking=no",
|
|
|
130 |
return {"message": response}
|
131 |
|
132 |
def post_process(output):
|
133 |
+
output = str(output)
|
134 |
lines = output.split("\n")
|
135 |
for line in lines:
|
136 |
for word in word_remove_sentence:
|
137 |
+
if string_found(word, line.lower()):
|
138 |
lines.remove(line)
|
139 |
break
|
140 |
|
|
|
142 |
for item in map_words.keys():
|
143 |
output = re.sub(item, map_words[item], output, re.I)
|
144 |
|
145 |
+
return output.strip()
|
146 |
+
|
147 |
+
def string_found(string1, string2):
|
148 |
+
if re.search(r"\b" + re.escape(string1) + r"\b", string2):
|
149 |
+
return True
|
150 |
+
return False
|
151 |
|
152 |
|
153 |
subprocess.Popen(["autossh", "-M", "0", "-o", "StrictHostKeyChecking=no",
|