Spaces:
Sleeping
Sleeping
File size: 1,727 Bytes
cf9ac63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
from src.recommender import GiftRecommender
def main():
recommender = GiftRecommender()
print("\nπ Gift Recommendation System")
print("-" * 30)
print("Example: '25-year-old sister who loves painting and traveling'")
print("Or simply enter an interest like 'games' or 'sports'.")
while True:
try:
text = input("\nWho are you shopping for? ('quit' to exit): ").strip()
if text.lower() == 'quit':
break
if len(text) < 3:
print("β οΈ Please provide more details or a valid interest.")
continue
# Get recommendations
results = recommender.get_gift_recommendations(text)
# If no structured interests found, assume the input itself is an interest
if not results['profile']['interests']:
print(f"\nπ No specific interests found, assuming '{text}' is the interest.")
results['profile']['interests'].append({'phrase': text, 'category': text, 'confidence': 1.0, 'sentiment': 'POSITIVE', 'sentiment_score': 1.0})
# Fetch new recommendations based on this interest
results['recommendations'] = recommender.generate_gift_ideas(text)
print("\n" + recommender.format_recommendations(results))
print("\nπ Suggested Gifts:")
for i, rec in enumerate(results['recommendations'], 1):
print(f"{i}. {rec['gift']}")
except Exception as e:
print(f"\nβ Error: {str(e)}")
print("π Please try again with different wording.")
if __name__ == "__main__":
main()
|