Skip to content

Commit

Permalink
Fixes #79, New script printing random crawl
Browse files Browse the repository at this point in the history
  • Loading branch information
JolanThomassin committed Mar 14, 2024
1 parent 1836081 commit 1510b8d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
45 changes: 45 additions & 0 deletions bin/testing-current-score.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import ailab.db as db

from ailab.db.finesse.test_queries import get_random_document_score


class NoChunkFoundError(Exception):
pass


## This is a comment.
def evaluate_random_document(project_db):

if project_db is None:
print("Database connection failed.")
return None

with project_db.cursor() as cursor:

random_chunk = get_random_document_score(cursor, "louis_v005")

if not random_chunk:
raise NoChunkFoundError("No chunk found in the database.")

print("\n-------------")
print("crawl_id:", random_chunk[0]["crawl_id"])
print("crawl_url:", random_chunk[0]["crawl_url"])
print("\n")

print("-------------")
for chunk in random_chunk:
print("score_type:", chunk["score_type"])
print("score:", chunk["score"])
print("\n")

return



def main():
project_db = db.connect_db()
evaluate_random_document(project_db)


if __name__ == "__main__":
main()
6 changes: 6 additions & 0 deletions bin/testing-current-score.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
DIRNAME=$(dirname "$0")
. "$DIRNAME"/lib.sh


PYTHONPATH=$PROJECT_DIR python "$DIRNAME"/testing-current-score.py

0 comments on commit 1510b8d

Please sign in to comment.