-
Notifications
You must be signed in to change notification settings - Fork 0
/
recruiter-keywords.py
executable file
·59 lines (46 loc) · 1.51 KB
/
recruiter-keywords.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
#!/usr/bin/env python
"""
What is a keyword? Glad you asked!
- A word with a non-initial capital.
- A word with no lowercase letters.
- A word in a known list of keywords.
"""
import re
import sys
types = {
'mobile': ['ios', 'blackberry', 'android', 'iphone', 'app', 'apps'],
'companies': ['facebook', 'google', 'microsoft', 'apple', 'yahoo', 'adobe'],
'languages': ['python', 'ruby', 'perl', 'java', 'c', 'c++'],
'frameworks': ['rails', 'django', 'sinatra', 'flask'],
'OSes': ['linux', 'windows', 'mac', 'dos', 'solaris', 'bsd'],
'data': ['mysql', 'mongo', 'redis', 'memcached', 'sql']
}
all_keywords = set()
for name, vals in types.iteritems():
all_keywords.update(vals)
def non_initial_capital(word):
return re.search('^.+[A-Z]', word)
def all_uppercase(word):
return word.isupper()
def letters_and_numbers(word):
return any(lambda c: c.isdigit()) and any(lambda c: c.isalpha())
def known_keyword(word):
return word.lower() in all_keywords
matchers = [non_initial_capital, all_uppercase, known_keyword]
def is_keyword(word):
for f in matchers:
if f(word):
return True
return False
def process(stream):
found_keywords = set()
for line in stream:
for word in re.split('[\s,/:.()-]', line):
if not word:
continue
if is_keyword(word) and word not in found_keywords:
found_keywords.add(word)
print word
if __name__ == '__main__':
f = open(sys.argv[1], 'r')
process(f)