Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textcompare #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
altair
pandas
streamlit
difflib
52 changes: 19 additions & 33 deletions streamlit_app.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
import altair as alt
import numpy as np
import pandas as pd
from difflib import SequenceMatcher
import streamlit as st

"""
# Welcome to Streamlit!
def calcular_similaridade(texto1, texto2):
# Criar um objeto SequenceMatcher com os textos dos arquivos
seq_matcher = SequenceMatcher(False, texto1, texto2)

Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
forums](https://discuss.streamlit.io).
# Obter a similaridade normalizada entre 0 e 1
similaridade_ponderada = seq_matcher.ratio()

In the meantime, below is an example of what you can do with just a few lines of code:
"""
return similaridade_ponderada

num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
# Exemplo de uso
st.title('Comparação de textos!')
st.title(':blue[Isis] :sunglasses:')
texto1 = st.text_input(
"Entre com o primeiro texto 👇",
)
texto2 = st.text_input(
"Entre com o segundo texto 👇",
)

indices = np.linspace(0, 1, num_points)
theta = 2 * np.pi * num_turns * indices
radius = indices
similaridade = calcular_similaridade(texto1, texto2)
st.text('Indice de similaridade entre os textos.')
st.text(similaridade)

x = radius * np.cos(theta)
y = radius * np.sin(theta)

df = pd.DataFrame({
"x": x,
"y": y,
"idx": indices,
"rand": np.random.randn(num_points),
})

st.altair_chart(alt.Chart(df, height=700, width=700)
.mark_point(filled=True)
.encode(
x=alt.X("x", axis=None),
y=alt.Y("y", axis=None),
color=alt.Color("idx", legend=None, scale=alt.Scale()),
size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
))