-
Notifications
You must be signed in to change notification settings - Fork 144
/
parser_rules.py
133 lines (114 loc) · 2.77 KB
/
parser_rules.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
import re
def extract_email(s, line):
email = None
match = re.search(r'[\w\.-]+@[\w\.-]+', line)
if match is not None:
email = match.group(0)
return email
def extract_sex(parts, line):
sex_found = False
sex = None
for w in parts:
if 'sex' in w:
sex_found = True
continue
if sex_found and ':' not in w:
if w == 'male':
sex = 'male'
else:
sex = 'female'
break
return sex
def extract_education(parts, line):
found = False
education = None
for w in parts:
if 'education' in w:
found = True
continue
if found and ':' not in w:
education = w
break
return education
def extract_mobile(parts, line):
found = False
education = None
for w in parts:
if 'mobile' in w:
found = True
continue
if found and ':' not in w:
education = w
break
return education
def extract_experience(parts, line):
found = False
result = None
for w in parts:
if w.find('experience') != -1:
found = True
continue
if found and ':' not in w:
result = w
break
return result
def extract_expertise(parts, line):
length = 4
line = line.lower()
index = line.find('know')
if index == -1:
length = 2
index = line.find('familiar')
if index == -1:
length = 2
index = line.find('use')
if index == -1:
length = 2
index = line.find('master')
if index == -1:
length = 4
index = line.find('understand')
if index == -1:
length = 4
index = line.find('develop')
result = None
if index == -1:
return None
else:
result = line[index + length:].replace(':', '').strip()
if result == '':
return None
return result
def extract_ethnicity(parts, line):
race_found = False
race = None
for w in parts:
if w.find('race') != -1:
race_found = True
continue
if race_found and w.find(':') == -1:
race = w
break
return race
def extract_name(parts, line):
found = False
result = None
for w in parts:
if w.find('name') != -1:
found = True
continue
if found and w.find(':') == -1:
result = w
break
return result
def extract_objective(parts, line):
found = False
result = None
for w in parts:
if w.find('objective') != -1:
found = True
continue
if found and ':' not in w:
result = w
break
return result