case sensitivity, updating challenges

This commit is contained in:
Silen Naihin
2023-10-20 08:26:29 -07:00
parent 0e51b12d61
commit 825c3adf62
7 changed files with 13 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
"eval_id": "6e2bf1f0-6842-4704-8ed1-b17c2065bbac",
"ground": {
"answer": "The csv labelled",
"case_sensitive": true,
"eval": {
"type": "file"
},

View File

@@ -10,6 +10,7 @@
"eval_id": "1758058c-f726-484f-96fa-f05e278e5ff5",
"ground": {
"answer": "The twitter handles of the two hosts of Latent Space.",
"case_sensitive": false,
"eval": {
"type": "file"
},

View File

@@ -10,6 +10,7 @@
"eval_id": "1758058c-f726-484f-96fa-f05e278e5ff5",
"ground": {
"answer": "Toran is from Scotland https://uk.linkedin.com/in/toran-richards.",
"case_sensitive": true,
"eval": {
"type": "file"
},
@@ -17,7 +18,7 @@
"output.txt"
],
"should_contain": [
"cotland"
"Scotland"
],
"should_not_contain": []
},

View File

@@ -11,6 +11,7 @@
"eval_id": "1758058c-f726-484f-96fa-f05e278e5ff5",
"ground": {
"answer": "https://www.amazon.com/gp/bestsellers/2021/books, second book, the answer is Reed",
"case_sensitive": true,
"eval": {
"type": "file"
},

View File

@@ -11,6 +11,7 @@
"eval_id": "1758058c-f726-484f-96fa-f05e278e5ff5",
"ground": {
"answer": "Get to https://www.forbes.com/special-report/2012/30-under-30/30-under-30_games.html, then https://www.linkedin.com/in/brianjcho/details/experience/ is the first 27 year old, then find his longest working job on Linkedin which is Riot Games.",
"case_sensitive": true,
"eval": {
"type": "file"
},

View File

@@ -123,6 +123,9 @@ class Challenge(ABC):
print("\033[1;34mScoring content:\033[0m", content)
if ground.should_contain:
for should_contain_word in ground.should_contain:
if not getattr(ground, 'case_sensitive', True):
should_contain_word = should_contain_word.lower()
content = content.lower()
print_content = (
f"\033[1;34mWord that should exist\033[0m - {should_contain_word}:"
)
@@ -134,6 +137,9 @@ class Challenge(ABC):
if ground.should_not_contain:
for should_not_contain_word in ground.should_not_contain:
if not getattr(ground, 'case_sensitive', True):
should_not_contain_word = should_not_contain_word.lower()
content = content.lower()
print_content = f"\033[1;34mWord that should not exist\033[0m - {should_not_contain_word}:"
if should_not_contain_word in content:
print(print_content, "False")

View File

@@ -165,6 +165,7 @@ class Ground(BaseModel):
should_contain: Optional[List[str]] = None
should_not_contain: Optional[List[str]] = None
files: List[str]
case_sensitive: Optional[bool] = True
eval: Eval