-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #79, New script printing random crawl
- Loading branch information
1 parent
1836081
commit 1510b8d
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |