robertou2 commited on
Commit
315486a
·
1 Parent(s): a1d3912

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -27
app.py CHANGED
@@ -28,33 +28,7 @@ auth.set_access_token(access_token, access_token_secret)
28
  api = tw.API(auth, wait_on_rate_limit=True)
29
 
30
 
31
- def preprocess(text):
32
 
33
- text=text.lower()
34
- # remove hyperlinks
35
- text = re.sub(r'https?:\/\/.*[\r\n]*', '', text)
36
- text = re.sub(r'http?:\/\/.*[\r\n]*', '', text)
37
- #Replace &amp, &lt, &gt with &,<,> respectively
38
- text=text.replace(r'&amp;?',r'and')
39
- text=text.replace(r'&lt;',r'<')
40
- text=text.replace(r'&gt;',r'>')
41
- #remove hashtag sign
42
- #text=re.sub(r"#","",text)
43
- #remove mentions
44
- text = re.sub(r"(?:\@)\w+", '', text)
45
- #text=re.sub(r"@","",text)
46
- #remove non ascii chars
47
- text=text.encode("ascii",errors="ignore").decode()
48
- #remove some puncts (except . ! ?)
49
- text=re.sub(r'[:"#$%&\*+,-/:;<=>@\\^_`{|}~]+','',text)
50
- text=re.sub(r'[!]+','!',text)
51
- text=re.sub(r'[?]+','?',text)
52
- text=re.sub(r'[.]+','.',text)
53
- text=re.sub(r"'","",text)
54
- text=re.sub(r"\(","",text)
55
- text=re.sub(r"\)","",text)
56
- text=" ".join(text.split())
57
- return text
58
 
59
  st.title('Analisis de comentarios sexistas en Twitter con Tweepy and HuggingFace Transformers')
60
  st.markdown('Esta app utiliza tweepy para descargar tweets de twitter en base a la información de entrada y procesa los tweets usando transformers de HuggingFace para detectar comentarios sexistas. El resultado y los tweets correspondientes se almacenan en un dataframe para mostrarlo que es lo que se ve como resultado')
@@ -68,7 +42,6 @@ def run():
68
  tweets =tw.Cursor(api.search_tweets,q=search_words).items(number_of_tweets)
69
  tweet_list = [i.text for i in tweets]
70
  text= pd.DataFrame(tweet_list)
71
- text[0] = text[0].apply(preprocess)
72
  text1=text[0].values
73
  indices1=tokenizer.batch_encode_plus(text1.tolist(),
74
  max_length=128,
 
28
  api = tw.API(auth, wait_on_rate_limit=True)
29
 
30
 
 
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  st.title('Analisis de comentarios sexistas en Twitter con Tweepy and HuggingFace Transformers')
34
  st.markdown('Esta app utiliza tweepy para descargar tweets de twitter en base a la información de entrada y procesa los tweets usando transformers de HuggingFace para detectar comentarios sexistas. El resultado y los tweets correspondientes se almacenan en un dataframe para mostrarlo que es lo que se ve como resultado')
 
42
  tweets =tw.Cursor(api.search_tweets,q=search_words).items(number_of_tweets)
43
  tweet_list = [i.text for i in tweets]
44
  text= pd.DataFrame(tweet_list)
 
45
  text1=text[0].values
46
  indices1=tokenizer.batch_encode_plus(text1.tolist(),
47
  max_length=128,