| import streamlit as st |
| import requests |
| from bs4 import BeautifulSoup |
| from transformers import pipeline |
|
|
| |
| classifier = pipeline("text-classification", model="pandalla/MBTIGPT_en_ENTP") |
|
|
| def scrape_mbti_lounge(mbti_type): |
| url = f"https://mbtilounge.com/mbti/{mbti_type}" |
| response = requests.get(url) |
| soup = BeautifulSoup(response.text, 'html.parser') |
| |
| description = soup.find('div', class_='type-description').text |
| return description |
|
|
| st.title("MBTI Lookup and Classification") |
|
|
| user_input = st.text_area("Enter text to classify MBTI type:") |
|
|
| if user_input: |
| |
| result = classifier(user_input)[0] |
| predicted_type = result['label'] |
| confidence = result['score'] |
|
|
| st.write(f"Predicted MBTI Type: {predicted_type}") |
| st.write(f"Confidence: {confidence:.2f}") |
|
|
| |
| description = scrape_mbti_lounge(predicted_type) |
| st.subheader(f"Description for {predicted_type}:") |
| st.write(description) |
|
|