-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analyser.py
48 lines (38 loc) · 1.69 KB
/
Analyser.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
38
39
40
41
42
43
44
45
46
47
48
import json
file = open("DataSets/trainingdata.txt", 'r')
dict = {}
common_words = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
"v", "w", "x", "y", "z", "between", "name",
"making", "should", "there", "under", "because", "made", "than", "their", "take", "more", "show", "set",
"our", "could", "will", "well", "two", "new", "with", "were", "did", "say", "out", "no", "are", "and",
"or", "of", "to", "a", "as", "also", "an", "at", "we", "u", "for", "from", "the", "if", "he",
"\n", "then", "not", "from", "it", "cut", "about", "months", "other",
"they", "any", "can", "its", "have", "had", "in", "on", "only", "but", "s", "up", "by", "now",
"said", "be", "was", "been", "into", "all", "over", "who", "do",
"what", "when", "which", "would", "his", "him", "has", "that", "while", "after", "today", "them"]
position = 0
for line in file:
words = line.split(" ")
classified = words[0]
words = words[1:]
for word in words:
if word not in common_words:
if word not in dict:
dict[word] = {"position":position}
position += 1
if classified not in dict[word]:
dict[word][classified] = 0
dict[word][classified] += 1
new_dict = {}
i = 0
for key in dict:
sum = 0
for Key in dict[key]:
if Key != "position":
sum += dict[key][Key]
if sum > 400:
new_dict[key] = {"position": i}
i += 1
outfile = open("DataSets/dataset50transpose.json", "w")
json.dump(new_dict, outfile, indent=4)
outfile.close()