forked from amitKr85/project_student_allocation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.py
180 lines (98 loc) · 3.52 KB
/
test1.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import pickle
import urllib
import urllib.request as url
from urllib.parse import quote
from bs4 import BeautifulSoup as bs
#from dict import v_set
import bleach
import re
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
#from dict import *
import time
#from synoskill import sksyno
skillobj = set()
skilldict = set()
#syno = set(["expertise", "skilfulness", "expertness", "adeptness", "adroitness", "deftness", "dexterity", "ability", "prowess", "mastery", "competence", "competency", "capability", "efficiency", "aptitude", "artistry", "art", "finesse", "flair", "virtuosity", "experience", "professionalism", "talent", "cleverness", "smartness", "ingenuity", "versatility", "knack", "readiness", "handiness"])
def allletter(s,str):
for c in s:
if c ==' ':
continue
if c not in str:
return 0
return 1
str="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM "
skill_set_file = open("pickled_data/final_skill_dict_2.pickle","rb")
# skill_set is a set() containing skills from linkedIn and wiki
counter =0
skill_set = pickle.load(skill_set_file)
for skill in skill_set:
if counter < 80 and allletter(skill,str):
# print(skill)
skilldict.add(skill)
counter = counter + 1
for dic in skilldict:
print(dic)
skill_set_file.close()
'''''
global stop_words
stop_words = set(stopwords.words('english'))
v2_set = set()
import requests
#url = raw_input("en.wikipedia.org/wiki")
for v in skill_set:
original = v
removed = original.replace("-", " ")
time.sleep(.5)
print('------------------------------------------',v,'-----------------------')
article= removed
#print(article)
article = quote(article)
from urllib.request import urlopen
def find_bad_qn(a):
url ="http://en.wikipedia.org/wiki/"+article
try:
urlopen(url)
except:
pass
# print("Please Wait.. it will take some time")
#for i in range(298314,298346):
# find_bad_qn(i)
sauce=urllib.request.urlopen("http://en.wikipedia.org/wiki/"+article).read()
soup=bs(sauce,'lxml')
vo_set = set()
w1=soup.find(attrs={'class':'mw-parser-output'})
#bleach.clean(w1, tags=[], attributes={}, styles=[], strip=True)
w2=w1.text
w3=word_tokenize(w2)
#print(w1.text)
for word in w3:
if word not in stop_words and word.__len__()>3 and word.isalpha():
vo_set.add(word)
for word in vo_set:
for wo in sksyno:
if wo.lower() == word.lower():
skilldict.add(wo)
else:
skillobj.add(wo)
print('--------------------skilldictionary-------------------')
for sw in skilldict:
print(sw)
print('---------------objectdictionary---------------')
for so in objdict:
print(so)
'''''
#if stop_words:
# print(word)
#for para in :
# print(para.string)
#data = r.text
#soup = BeautifulSoup(data,'html.parser')
#artist_name_list = soup.find(class_='BodyText')
#print(soup.find(class_='BodyText'))
#artist_name_list_items = artist_name_list.find_all('a')
# Use .contents to pull out the <a> tag’s children
#for artist_name in artist_name_list:
# names = artist_name.contents[0]
# print(names)
#print(soup.find('div',id="bodyContent").p)