Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- dictionary = json.load(open("saved_dictionary/my_dictionary.txt")) #wczytanie wcześniej utworzonego słownika, który zawiera hasła wraz z ich kategorią
- articlename = 'Poznań' #w cudzysłowiu znajduje się tytuł badanego artykułu
- text = open('savedcleantext/'+ articlename + '.txt', 'r', encoding='utf-8')
- plaintext = text.read() #wczytanie czystej treści danego artykułu
- c = {}
- columns=[]
- n = 0
- for key in dictionary.keys():
- values = dictionary[str(key)]
- n=0
- c={}
- for value in values:
- if value in plaintext:
- c[value] = c.get(value,0) + plaintext.count(value)
- n += c[value]
- sumvalue = len(c.keys())
- columns.append(key + "\t\t" + (key + '_unikat'))
- columnsString = "\t\t".join(columns)
- print("Nazwa artykułu" + "\t\t" + columnsString)
- print(articlename, end='')
- print(str(n).rjust(12) + str(sumvalue).rjust(18), end = '')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement