File size: 1,085 Bytes
4b23681
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import requests
from bs4 import BeautifulSoup
from transformers import pipeline

# Set up MBTI classifier
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')
    # Extract relevant information (adjust selectors as needed)
    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:
    # Classify MBTI type
    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}")

    # Fetch MBTI type description from MBTI Lounge
    description = scrape_mbti_lounge(predicted_type)
    st.subheader(f"Description for {predicted_type}:")
    st.write(description)