Skip to content
Snippets Groups Projects
Commit 516db59d authored by felixwelter's avatar felixwelter
Browse files

Use title focused search index

parent bb223217
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,8 @@ from pathlib import Path
import pdfplumber
from flask import Flask, render_template, request, redirect, send_file
from werkzeug.utils import secure_filename
from search_index import SearchIndex
from search_index import BasicSearchIndex
from title_focus_search_index import TitleFocusSearchIndex
import os
app = Flask(__name__)
......@@ -12,6 +13,7 @@ app = Flask(__name__)
SLIDE_DIR = "slides"
IMAGE_DIR = "img_cache"
Index = TitleFocusSearchIndex
@app.route('/')
def index():
......@@ -36,7 +38,7 @@ def upload():
file_path = os.path.join(Path(SLIDE_DIR), filename)
file.save(file_path)
pdf = pdfplumber.open(file_path)
index = SearchIndex()
index = Index()
for i, page in enumerate(pdf.pages):
text = page.extract_text()
index.add(str(file_path), i, text)
......@@ -49,7 +51,7 @@ def upload():
@app.route("/search")
def query():
try:
index = SearchIndex()
index = Index()
query = request.args.get("term")
result = index.search(query)
#pdf = pdfplumber.open(result["path"])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment