luisespinosa commited on
Commit
b77656f
•
1 Parent(s): 77783f2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -2
README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Twitter-roBERTa-base
2
 
3
- This is a roBERTa-base model trained on ~58M tweets and finetuned for the emotion prediction task at Semeval 2018.
4
  For full description: [_TweetEval_ benchmark (Findings of EMNLP 2020)](https://arxiv.org/pdf/2010.12421.pdf).
5
  To evaluate this and other models on Twitter-specific data, please refer to the [Tweeteval official repository](https://github.com/cardiffnlp/tweeteval).
6
 
@@ -15,6 +15,15 @@ from scipy.special import softmax
15
  import csv
16
  import urllib.request
17
 
 
 
 
 
 
 
 
 
 
18
  # Tasks:
19
  # emoji, emotion, hate, irony, offensive, sentiment
20
  # stance/abortion, stance/atheism, stance/climate, stance/feminist, stance/hillary
@@ -36,6 +45,7 @@ model = AutoModelForSequenceClassification.from_pretrained(MODEL)
36
  model.save_pretrained(MODEL)
37
 
38
  text = "Good night 😊"
 
39
  encoded_input = tokenizer(text, return_tensors='pt')
40
  output = model(**encoded_input)
41
  scores = output[0][0].detach().numpy()
 
1
+ # Twitter-roBERTa-base for Emotion Recognition
2
 
3
+ This is a roBERTa-base model trained on ~58M tweets and finetuned for the Emotion recogniton task at Semeval 2018.
4
  For full description: [_TweetEval_ benchmark (Findings of EMNLP 2020)](https://arxiv.org/pdf/2010.12421.pdf).
5
  To evaluate this and other models on Twitter-specific data, please refer to the [Tweeteval official repository](https://github.com/cardiffnlp/tweeteval).
6
 
 
15
  import csv
16
  import urllib.request
17
 
18
+ # Preprocess text (username and link placeholders)
19
+ def preprocess(text):
20
+ new_text = []
21
+ for t in text.split(" "):
22
+ t = '@user' if t.startswith('@') and len(t) > 1 else t
23
+ t = 'http' if t.startswith('http') else t
24
+ new_text.append(t)
25
+ return " ".join(new_text)
26
+
27
  # Tasks:
28
  # emoji, emotion, hate, irony, offensive, sentiment
29
  # stance/abortion, stance/atheism, stance/climate, stance/feminist, stance/hillary
 
45
  model.save_pretrained(MODEL)
46
 
47
  text = "Good night 😊"
48
+ text = preprocess(text)
49
  encoded_input = tokenizer(text, return_tensors='pt')
50
  output = model(**encoded_input)
51
  scores = output[0][0].detach().numpy()