Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import requests
|
3 |
+
from bs4 import BeautifulSoup
|
4 |
+
from transformers import pipeline
|
5 |
+
|
6 |
+
# Set up MBTI classifier
|
7 |
+
classifier = pipeline("text-classification", model="pandalla/MBTIGPT_en_ENTP")
|
8 |
+
|
9 |
+
def scrape_mbti_lounge(mbti_type):
|
10 |
+
url = f"https://mbtilounge.com/mbti/{mbti_type}"
|
11 |
+
response = requests.get(url)
|
12 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
13 |
+
# Extract relevant information (adjust selectors as needed)
|
14 |
+
description = soup.find('div', class_='type-description').text
|
15 |
+
return description
|
16 |
+
|
17 |
+
st.title("MBTI Lookup and Classification")
|
18 |
+
|
19 |
+
user_input = st.text_area("Enter text to classify MBTI type:")
|
20 |
+
|
21 |
+
if user_input:
|
22 |
+
# Classify MBTI type
|
23 |
+
result = classifier(user_input)[0]
|
24 |
+
predicted_type = result['label']
|
25 |
+
confidence = result['score']
|
26 |
+
|
27 |
+
st.write(f"Predicted MBTI Type: {predicted_type}")
|
28 |
+
st.write(f"Confidence: {confidence:.2f}")
|
29 |
+
|
30 |
+
# Fetch MBTI type description from MBTI Lounge
|
31 |
+
description = scrape_mbti_lounge(predicted_type)
|
32 |
+
st.subheader(f"Description for {predicted_type}:")
|
33 |
+
st.write(description)
|