asahi417 commited on
Commit
b36dafa
1 Parent(s): 5fb2549

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -0
README.md CHANGED
@@ -50,6 +50,29 @@ of "Takin' Off" Album from {@Herbie Hancock@}
50
  via {{USERNAME}} link below: {{URL}}
51
  ```
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  We ask annotators to ignore those special tokens but label the verified users' mentions.
54
 
55
 
 
50
  via {{USERNAME}} link below: {{URL}}
51
  ```
52
 
53
+ A simple function to format tweet follows below.
54
+
55
+ ```python
56
+ import re
57
+ from urlextract import URLExtract
58
+ extractor = URLExtract()
59
+
60
+ def format_tweet(tweet):
61
+ # mask web urls
62
+ urls = extractor.find_urls(tweet)
63
+ for url in urls:
64
+ tweet = tweet.replace(url, "{{URL}}")
65
+ # format twitter account
66
+ tweet = re.sub(r"\b(\s*)(@[\S]+)\b", r'\1{\2@}', tweet)
67
+ return tweet
68
+
69
+ target = tweet = """Get the all-analog Classic Vinyl Edition of "Takin' Off" Album from @herbiehancock via @bluenoterecords link below: http://bluenote.lnk.to/AlbumOfTheWeek"""
70
+ target_format = format_tweet(target)
71
+ print(target_format)
72
+ 'Get the all-analog Classic Vinyl Edition of "Takin\' Off" Album from {@herbiehancock@} via {@bluenoterecords@} link below: {{URL}}'
73
+ ```
74
+
75
+
76
  We ask annotators to ignore those special tokens but label the verified users' mentions.
77
 
78