Skip to content

Commit

Permalink
refactor: Add reverse parameter to detect_folio method
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik172 committed Jul 21, 2024
1 parent 4197524 commit 6deb47e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/services/folio.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def __init__(self):
self.filename = None
self.client = cohere.Client(api_key=os.getenv('COHERE_API_KEY'))

def detect_folio(self, pdf_file: str | bytes, result_id: str):
def detect_folio(self, pdf_file: str | bytes, result_id: str, reverse: bool = False) -> None:
work_status = WorkStatus.query.filter_by(result_id=result_id).first()

self.filename = pdf_file.split('/')[-1]

if isinstance(pdf_file, str):
Expand All @@ -50,7 +51,7 @@ def detect_folio(self, pdf_file: str | bytes, result_id: str):
folio_image = self._crop_folio(page, folio_box)
folio_text = self._ocr_folio(folio_image)

if folio_text is None and self.text1 is not None:
if folio_text is None and self.text1 is not None and reverse == True:
self.text2 = pytesseract.image_to_string(page)
is_reverse, tokens = self._is_reverse(self.text1, self.text2)

Expand Down

0 comments on commit 6deb47e

Please sign in to comment.