-
Notifications
You must be signed in to change notification settings - Fork 0
/
iramuteq_usage.py
37 lines (29 loc) · 1.17 KB
/
iramuteq_usage.py
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
35
36
37
# -*- coding: utf-8 -*-
import re
class Iramuteq:
def __init__(self, nodes, scraped_tweets, variables):
self.nodes = nodes
self.tweets = self.get_used_tweets(scraped_tweets)
self.variables = variables
def get_used_tweets(self, scraped_tweets):
tweets_content = []
for node in self.nodes:
for tweet in scraped_tweets:
if node['Id'] == tweet['Id']:
tweets_content.append(tweet['content'])
return tweets_content
def create_file(self, filename):
iramuteq_file = open(
f'./iramuteq_files/{filename}.txt',
"w", encoding="utf-8")
inicia_comando = "*" * 4
for i in range(len(self.tweets)):
p = re.compile('\w+') # retira todos os simbolos não alfa-numericos
description = p.findall(self.tweets[i])
description = ' '.join(description)
line = f'{inicia_comando} '
for variable in self.variables:
line += f'*{variable} '
line += f'\n{description}\n\n'
iramuteq_file.write(line)
print(f'Iramuteq file written in iramuteq_files/{filename}')