Skip to content

Commit

Permalink
Improved query
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSel committed Nov 13, 2023
1 parent f37832b commit de2ab39
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions apps/services/food_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class RatingModel(BaseModel):
service: RatingItem = Field(..., description="The service-only rating")
atmosphere: RatingItem = Field(..., description="The atmosphere-only rating")
location: RatingItem = Field(..., description="The location-only rating")
best_dishes: List[str] = Field(..., description="The best dishes based on reviews")


@Monkey.patch
Expand All @@ -51,6 +52,8 @@ def specific_ratings(reviews: List[str]) -> RatingModel:
- location
rating: 1-10
confidence: 1-10
- best_dishes
list of strings
"""


Expand All @@ -62,12 +65,14 @@ def test_specific_ratings():
service=RatingItem(rating=5, confidence=1),
atmosphere=RatingItem(rating=5, confidence=1),
location=RatingItem(rating=5, confidence=1),
best_dishes=[],
)
assert specific_ratings(["The service was great"]) == RatingModel(
food=RatingItem(rating=5, confidence=1),
service=RatingItem(rating=10, confidence=10),
atmosphere=RatingItem(rating=5, confidence=1),
location=RatingItem(rating=5, confidence=1),
best_dishes=[],
)
assert specific_ratings(
[
Expand All @@ -78,6 +83,7 @@ def test_specific_ratings():
service=RatingItem(rating=1, confidence=10),
atmosphere=RatingItem(rating=5, confidence=10),
location=RatingItem(rating=10, confidence=10),
best_dishes=[],
)
assert specific_ratings(
[
Expand All @@ -88,6 +94,7 @@ def test_specific_ratings():
service=RatingItem(rating=4, confidence=10),
atmosphere=RatingItem(rating=7, confidence=10),
location=RatingItem(rating=9, confidence=10),
best_dishes=[],
)
assert specific_ratings(
[
Expand All @@ -99,8 +106,50 @@ def test_specific_ratings():
service=RatingItem(rating=5, confidence=1),
atmosphere=RatingItem(rating=5, confidence=1),
location=RatingItem(rating=5, confidence=1),
best_dishes=[],
)

assert specific_ratings(
[
"The lobster was YUMMY, but we didn't like the steak",

]
) == RatingModel(
food=RatingItem(rating=5, confidence=5),
service=RatingItem(rating=5, confidence=1),
atmosphere=RatingItem(rating=5, confidence=1),
location=RatingItem(rating=5, confidence=1),
best_dishes=['Lobster'],
)
assert specific_ratings(
[
"The food is overall amazing! Must haves: Steak, Spaghetti Bloufori, Norma alla Forma. The burger was fine..",

]
) == RatingModel(
food=RatingItem(rating=9, confidence=10),
service=RatingItem(rating=5, confidence=1),
atmosphere=RatingItem(rating=5, confidence=1),
location=RatingItem(rating=5, confidence=1),
best_dishes=['Steak, Spagetthi Bloufori, Norma alla Forma'],
)
assert specific_ratings(
[
"I loved the Fries",
"I hated the fish",
"Yummy poridge",
"Best burger ever",
"Rice was too salty",
]
) == RatingModel(
food=RatingItem(rating=9, confidence=5),
service=RatingItem(rating=5, confidence=1),
atmosphere=RatingItem(rating=5, confidence=1),
location=RatingItem(rating=5, confidence=1),
best_dishes=['Fries', 'Porridge', 'Burger'],
)



@Monkey.patch
def recommended_dishes(reviews: List[str]) -> List[str]:
Expand Down

0 comments on commit de2ab39

Please sign in to comment.