Omar ID EL MOUMEN
commited on
Commit
·
2c3f79c
1
Parent(s):
e584cfd
Change scope function
Browse files
app.py
CHANGED
@@ -131,23 +131,19 @@ def get_scope(specification: str, version: str):
|
|
131 |
try:
|
132 |
spec_text = get_text(specification, version)
|
133 |
scp_i = 0
|
|
|
134 |
for x in range(len(spec_text)):
|
135 |
text = spec_text[x]
|
136 |
-
if re.search(r"
|
137 |
scp_i = x
|
138 |
-
|
139 |
-
|
140 |
-
nxt_i = scp_i + 10
|
141 |
-
for x in range(len(spec_text[scp_i:])):
|
142 |
-
text = spec_text[x]
|
143 |
-
if re.search(r"^\d\s+references$", text.lower()):
|
144 |
nxt_i = x
|
145 |
-
break
|
146 |
|
147 |
-
return re.sub(r"\s+", " ", " ".join(spec_text[scp_i+1:nxt_i]))
|
148 |
except Exception as e:
|
149 |
traceback.print_exception(e)
|
150 |
-
return
|
151 |
|
152 |
class DocRequest(BaseModel):
|
153 |
doc_id: str
|
|
|
131 |
try:
|
132 |
spec_text = get_text(specification, version)
|
133 |
scp_i = 0
|
134 |
+
nxt_i = 0
|
135 |
for x in range(len(spec_text)):
|
136 |
text = spec_text[x]
|
137 |
+
if re.search(r"scope$", text, flags=re.IGNORECASE):
|
138 |
scp_i = x
|
139 |
+
nxt_i = scp_i + 10
|
140 |
+
if re.search(r"references$", text, flags=re.IGNORECASE):
|
|
|
|
|
|
|
|
|
141 |
nxt_i = x
|
|
|
142 |
|
143 |
+
return re.sub(r"\s+", " ", " ".join(spec_text[scp_i+1:nxt_i])) if len(spec_text[scp_i+1:nxt_i]) < 2 else "Not found"
|
144 |
except Exception as e:
|
145 |
traceback.print_exception(e)
|
146 |
+
return "Not found (error)"
|
147 |
|
148 |
class DocRequest(BaseModel):
|
149 |
doc_id: str
|