Remove "Get document content" button
Browse files- app.py +2 -112
- static/script.js +1 -16
app.py
CHANGED
@@ -479,7 +479,7 @@ def search_spec(request: KeywordRequest):
|
|
479 |
put = True
|
480 |
if docValid:
|
481 |
for chapter in list(doc.keys())[1:]:
|
482 |
-
if "references" not in chapter.lower():
|
483 |
if all(kw in willLower(doc[chapter], booleanLowered) for kw in kws):
|
484 |
put = True
|
485 |
contents.append(chapter)
|
@@ -488,16 +488,14 @@ def search_spec(request: KeywordRequest):
|
|
488 |
put = True
|
489 |
if docValid:
|
490 |
for chapter in list(doc.keys())[1:]:
|
491 |
-
if "references" not in chapter.lower():
|
492 |
if any(kw in willLower(doc[chapter], booleanLowered) for kw in kws):
|
493 |
put = True
|
494 |
contents.append(chapter)
|
495 |
|
496 |
if put:
|
497 |
spec_content = spec
|
498 |
-
spec_content["full_doc"] = doc
|
499 |
spec_content["contains"] = {chap: doc[chap] for chap in contents}
|
500 |
-
|
501 |
results.append(spec_content)
|
502 |
else:
|
503 |
unique_specs.add(spec['id'])
|
@@ -509,114 +507,6 @@ def search_spec(request: KeywordRequest):
|
|
509 |
else:
|
510 |
raise HTTPException(status_code=404, detail="Specifications not found")
|
511 |
|
512 |
-
# @app.post("/search-spec", response_model=KeywordResponse)
|
513 |
-
# def search_spec(request: KeywordRequest):
|
514 |
-
# start_time = time.time()
|
515 |
-
# kws = [_.lower() for _ in request.keywords.split(" ")]
|
516 |
-
# results = []
|
517 |
-
|
518 |
-
# for string, spec in finder_spec.indexer_specs.items():
|
519 |
-
# if request.mode == "and":
|
520 |
-
# if not all(kw in string.lower() for kw in kws):
|
521 |
-
# continue
|
522 |
-
# elif request.mode == "or":
|
523 |
-
# if not any(kw in string.lower() for kw in kws):
|
524 |
-
# continue
|
525 |
-
# release = request.release
|
526 |
-
# working_group = request.wg
|
527 |
-
# spec_type = request.spec_type
|
528 |
-
|
529 |
-
# if spec.get('version', None) is None or (release is not None and spec["version"].split(".")[0] != str(release)):
|
530 |
-
# continue
|
531 |
-
# if spec.get('working_group', None) is None or (working_group is not None and spec["working_group"] != working_group):
|
532 |
-
# continue
|
533 |
-
# if spec_type is not None and spec["type"] != spec_type:
|
534 |
-
# continue
|
535 |
-
|
536 |
-
# results.append(spec)
|
537 |
-
# if len(results) > 0:
|
538 |
-
# return KeywordResponse(
|
539 |
-
# results=results,
|
540 |
-
# search_time=time.time() - start_time
|
541 |
-
# )
|
542 |
-
# else:
|
543 |
-
# raise HTTPException(status_code=404, detail="Specifications not found")
|
544 |
-
|
545 |
-
# def search_spec(request: KeywordRequest):
|
546 |
-
# chars = "0123456789abcdefghijklmnopqrstuvwxyz"
|
547 |
-
# start_time = time.time()
|
548 |
-
# response = requests.get(f'https://www.3gpp.org/dynareport?code=status-report.htm', headers={"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}, verify=False)
|
549 |
-
# dfs = pd.read_html(StringIO(response.text), storage_options={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}, encoding="utf-8")
|
550 |
-
|
551 |
-
# for x in range(len(dfs)):
|
552 |
-
# dfs[x] = dfs[x].replace({np.nan: None})
|
553 |
-
|
554 |
-
# columns_needed = [0, 1, 2, 3, 4]
|
555 |
-
# extracted_dfs: List[pd.DataFrame] = [df.iloc[:, columns_needed] for df in dfs]
|
556 |
-
# columns = [x.replace("\xa0", "_") for x in extracted_dfs[0].columns]
|
557 |
-
|
558 |
-
# specifications = []
|
559 |
-
|
560 |
-
# for df in extracted_dfs:
|
561 |
-
# for index, row in df.iterrows():
|
562 |
-
# doc = row.to_list()
|
563 |
-
# doc_dict = dict(zip(columns, doc))
|
564 |
-
# specifications.append(doc_dict)
|
565 |
-
|
566 |
-
# kws = [_.lower() for _ in request.keywords.split(" ")]
|
567 |
-
# results = []
|
568 |
-
|
569 |
-
# for spec in specifications:
|
570 |
-
# if request.mode == "and":
|
571 |
-
# if not all(kw in spec["title"].lower() for kw in kws):
|
572 |
-
# continue
|
573 |
-
# elif request.mode == "or":
|
574 |
-
# if not any(kw in spec["title"].lower() for kw in kws):
|
575 |
-
# continue
|
576 |
-
# release = request.release
|
577 |
-
# working_group = request.wg
|
578 |
-
# spec_type = request.spec_type
|
579 |
-
|
580 |
-
# if spec.get('vers', None) is None or (release is not None and spec["vers"].split(".")[0] != str(release)):
|
581 |
-
# continue
|
582 |
-
# if spec.get('WG', None) is None or (working_group is not None and spec["WG"] != working_group):
|
583 |
-
# continue
|
584 |
-
# if spec_type is not None and spec["type"] != spec_type:
|
585 |
-
# continue
|
586 |
-
|
587 |
-
# doc_id = str(spec["spec_num"])
|
588 |
-
# series = doc_id.split(".")[0]
|
589 |
-
# a, b, c = str(spec["vers"]).split(".")
|
590 |
-
# print(spec["vers"])
|
591 |
-
# if not (int(a) > 35 or int(b) > 35 or int(c) > 35):
|
592 |
-
# spec_url = f"https://www.3gpp.org/ftp/Specs/archive/{series}_series/{doc_id}/{doc_id.replace('.', '')}-{chars[int(a)]}{chars[int(b)]}{chars[int(c)]}.zip"
|
593 |
-
# else:
|
594 |
-
# x,y,z = str(a), str(b), str(c)
|
595 |
-
# while len(x) < 2:
|
596 |
-
# x = "0" + x
|
597 |
-
# while len(y) < 2:
|
598 |
-
# y = "0" + y
|
599 |
-
# while len(z) < 2:
|
600 |
-
# z = "0" + z
|
601 |
-
# spec_url = f"https://www.3gpp.org/ftp/Specs/archive/{series}_series/{doc_id}/{doc_id.replace('.', '')}-{x}{y}{z}.zip"
|
602 |
-
# results.append({
|
603 |
-
# "id": str(spec["spec_num"]),
|
604 |
-
# "title": spec["title"],
|
605 |
-
# "type": "Technical Specification" if spec["type"] == "TS" else "Technical Report",
|
606 |
-
# "release": str(spec["vers"].split(".")[0]),
|
607 |
-
# "version": str(spec["vers"]),
|
608 |
-
# "working_group": spec["WG"],
|
609 |
-
# "url": spec_url
|
610 |
-
# })
|
611 |
-
|
612 |
-
# if len(results) > 0:
|
613 |
-
# return KeywordResponse(
|
614 |
-
# results=results,
|
615 |
-
# search_time=time.time() - start_time
|
616 |
-
# )
|
617 |
-
# else:
|
618 |
-
# raise HTTPException(status_code=404, detail="Specification not found")
|
619 |
-
|
620 |
@app.post("/find", response_model=DocResponse)
|
621 |
def find_document(request: DocRequest):
|
622 |
start_time = time.time()
|
|
|
479 |
put = True
|
480 |
if docValid:
|
481 |
for chapter in list(doc.keys())[1:]:
|
482 |
+
if "references" not in chapter.lower() or "void" not in chapter.lower():
|
483 |
if all(kw in willLower(doc[chapter], booleanLowered) for kw in kws):
|
484 |
put = True
|
485 |
contents.append(chapter)
|
|
|
488 |
put = True
|
489 |
if docValid:
|
490 |
for chapter in list(doc.keys())[1:]:
|
491 |
+
if "references" not in chapter.lower() or "void" not in chapter.lower():
|
492 |
if any(kw in willLower(doc[chapter], booleanLowered) for kw in kws):
|
493 |
put = True
|
494 |
contents.append(chapter)
|
495 |
|
496 |
if put:
|
497 |
spec_content = spec
|
|
|
498 |
spec_content["contains"] = {chap: doc[chap] for chap in contents}
|
|
|
499 |
results.append(spec_content)
|
500 |
else:
|
501 |
unique_specs.add(spec['id'])
|
|
|
507 |
else:
|
508 |
raise HTTPException(status_code=404, detail="Specifications not found")
|
509 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
@app.post("/find", response_model=DocResponse)
|
511 |
def find_document(request: DocRequest):
|
512 |
start_time = time.time()
|
static/script.js
CHANGED
@@ -105,11 +105,7 @@ keywordSearchBtn.addEventListener("click", async ()=>{
|
|
105 |
headers: {
|
106 |
"Content-Type": "application/json"
|
107 |
},
|
108 |
-
body: JSON.stringify(
|
109 |
-
keywords,
|
110 |
-
"case_sensitive": caseSensitiveFilter.checked,
|
111 |
-
"mode": modeFilter.value
|
112 |
-
})
|
113 |
});
|
114 |
|
115 |
const data = await response.json();
|
@@ -271,7 +267,6 @@ function displayKeywordResults(data) {
|
|
271 |
</div>
|
272 |
<div class="result-actions">
|
273 |
<button class="get-section-btn btn" data-spec-id="${spec.id}">Get section</button>
|
274 |
-
<button class="get-all-text-btn btn" data-spec-id="${spec.id}">Get document content</button>
|
275 |
</div>
|
276 |
`;
|
277 |
|
@@ -280,11 +275,9 @@ function displayKeywordResults(data) {
|
|
280 |
|
281 |
// Récupérer le bouton nouvellement créé
|
282 |
const button1 = resultItem.querySelector('.get-section-btn');
|
283 |
-
const button2 = resultItem.querySelector('.get-all-text-btn');
|
284 |
|
285 |
// Stocker l'objet directement sur l'élément DOM
|
286 |
button1._sections = spec.contains;
|
287 |
-
button2._sections = spec.full_doc;
|
288 |
});
|
289 |
|
290 |
document.querySelectorAll('.get-section-btn').forEach(button => {
|
@@ -295,14 +288,6 @@ function displayKeywordResults(data) {
|
|
295 |
});
|
296 |
});
|
297 |
|
298 |
-
document.querySelectorAll('.get-all-text-btn').forEach(button => {
|
299 |
-
button.addEventListener('click', function() {
|
300 |
-
let specId = this.getAttribute("data-spec-id");
|
301 |
-
let sections = this._sections;
|
302 |
-
openSectionPopup(specId, sections);
|
303 |
-
})
|
304 |
-
});
|
305 |
-
|
306 |
resultsStats.textContent = `Found ${data.results.length} in ${data.search_time.toFixed(2)} seconds`
|
307 |
resultsContainer.style.display = 'block';
|
308 |
}
|
|
|
105 |
headers: {
|
106 |
"Content-Type": "application/json"
|
107 |
},
|
108 |
+
body: JSON.stringify(body)
|
|
|
|
|
|
|
|
|
109 |
});
|
110 |
|
111 |
const data = await response.json();
|
|
|
267 |
</div>
|
268 |
<div class="result-actions">
|
269 |
<button class="get-section-btn btn" data-spec-id="${spec.id}">Get section</button>
|
|
|
270 |
</div>
|
271 |
`;
|
272 |
|
|
|
275 |
|
276 |
// Récupérer le bouton nouvellement créé
|
277 |
const button1 = resultItem.querySelector('.get-section-btn');
|
|
|
278 |
|
279 |
// Stocker l'objet directement sur l'élément DOM
|
280 |
button1._sections = spec.contains;
|
|
|
281 |
});
|
282 |
|
283 |
document.querySelectorAll('.get-section-btn').forEach(button => {
|
|
|
288 |
});
|
289 |
});
|
290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
resultsStats.textContent = `Found ${data.results.length} in ${data.search_time.toFixed(2)} seconds`
|
292 |
resultsContainer.style.display = 'block';
|
293 |
}
|