Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -48,7 +48,34 @@ class CryptoCrew:
|
|
| 48 |
return parsed_result
|
| 49 |
|
| 50 |
def parse_result(self, result):
|
| 51 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
if __name__ == "__main__":
|
| 54 |
print("## Welcome to Crypto Analysis Crew")
|
|
@@ -61,4 +88,4 @@ if __name__ == "__main__":
|
|
| 61 |
print("\n\n########################")
|
| 62 |
print("## Here is the Report")
|
| 63 |
print("########################\n")
|
| 64 |
-
print(json.dumps(result, indent=2))
|
|
|
|
| 48 |
return parsed_result
|
| 49 |
|
| 50 |
def parse_result(self, result):
|
| 51 |
+
# Assuming `result` is an object with a method or attribute to get the text summary
|
| 52 |
+
try:
|
| 53 |
+
result_text = result.get_summary() # Replace with actual method/attribute
|
| 54 |
+
except AttributeError:
|
| 55 |
+
result_text = str(result)
|
| 56 |
+
|
| 57 |
+
parsed = {
|
| 58 |
+
"summary": result_text,
|
| 59 |
+
"sentiment": {
|
| 60 |
+
"overall": "Neutral",
|
| 61 |
+
"social_media": "Neutral",
|
| 62 |
+
"news": "Neutral",
|
| 63 |
+
"community": "Neutral"
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
if "sentiment score" in result_text.lower():
|
| 68 |
+
sentiment_section = result_text.split("sentiment score")[1].split("\n")[0]
|
| 69 |
+
try:
|
| 70 |
+
sentiment_score = float(sentiment_section.strip())
|
| 71 |
+
if sentiment_score > 0.5:
|
| 72 |
+
parsed["sentiment"]["overall"] = "Positive"
|
| 73 |
+
elif sentiment_score < -0.5:
|
| 74 |
+
parsed["sentiment"]["overall"] = "Negative"
|
| 75 |
+
except ValueError:
|
| 76 |
+
pass
|
| 77 |
+
|
| 78 |
+
return parsed
|
| 79 |
|
| 80 |
if __name__ == "__main__":
|
| 81 |
print("## Welcome to Crypto Analysis Crew")
|
|
|
|
| 88 |
print("\n\n########################")
|
| 89 |
print("## Here is the Report")
|
| 90 |
print("########################\n")
|
| 91 |
+
print(json.dumps(result, indent=2))
|