Spaces:
Runtime error
Runtime error
fix(predictor): fix age error
Browse files- predictor/__init__.py +4 -4
predictor/__init__.py
CHANGED
@@ -49,12 +49,12 @@ class Predictor():
|
|
49 |
self.name_pattern = re.compile(last_name + first_name)
|
50 |
self.phone_pattern = re.compile(r'1 {0,4}(3 {0,4}\d|4 {0,4}[5-9]|5 {0,4}[0-35-9]|6 {0,4}[2567]|7 {0,4}[0-8]|8 {0,4}\d|9 {0,4}[0-35-9]) {0,4}(\d {0,4}){8}')
|
51 |
self.email_pattern = re.compile(r'([a-zA-Z0-9_-] {0,4})+@([a-zA-Z0-9_-] {0,4})+(\. {0,4}([a-zA-Z0-9_-] {0,4})+)+')
|
52 |
-
self.gender_pattern = re.compile(r'(性 {0,8}别.*?)?\s*?(男|女)
|
53 |
self.age_patterns = [
|
54 |
-
re.compile(r"(\d{1,2})岁|年龄.{0,10}(\d{1,2})"),
|
55 |
re.compile(r"生.{0,12}(([12]\d{3})[年|.]?(([01]?\d)[月|.]?)?(([0-3]?\d)[日|.]?)?)"),
|
56 |
]
|
57 |
-
self.works_key_pattern = re.compile("
|
58 |
self.job_time_patterns = re.compile('([1-2]\d{3}(\D?[01]?\d){0,2})\D?([1-2]\d{3}(\D?[01]?\d){0,2}|至今)')
|
59 |
self.edu_index = ["博士","硕士","研究生","学士","本科","大专","专科","中专","高中","初中","小学"]
|
60 |
self.edu_patterns = list(re.compile(i) for i in self.edu_index)
|
@@ -235,7 +235,7 @@ class Predictor():
|
|
235 |
s,e = age_match.span(1)
|
236 |
elif age_match.group(2) is not None:
|
237 |
age = age_match.group(2)
|
238 |
-
s,e = age_match.span(
|
239 |
if age is not None:
|
240 |
return_obj['age'].append({
|
241 |
'start': index_mapper[s],
|
|
|
49 |
self.name_pattern = re.compile(last_name + first_name)
|
50 |
self.phone_pattern = re.compile(r'1 {0,4}(3 {0,4}\d|4 {0,4}[5-9]|5 {0,4}[0-35-9]|6 {0,4}[2567]|7 {0,4}[0-8]|8 {0,4}\d|9 {0,4}[0-35-9]) {0,4}(\d {0,4}){8}')
|
51 |
self.email_pattern = re.compile(r'([a-zA-Z0-9_-] {0,4})+@([a-zA-Z0-9_-] {0,4})+(\. {0,4}([a-zA-Z0-9_-] {0,4})+)+')
|
52 |
+
self.gender_pattern = re.compile(r'(性 {0,8}别.*?)?\s*?(男|女)')
|
53 |
self.age_patterns = [
|
54 |
+
re.compile(r"(\d{1,2})岁|年龄.{0,10}?(\d{1,2})"),
|
55 |
re.compile(r"生.{0,12}(([12]\d{3})[年|.]?(([01]?\d)[月|.]?)?(([0-3]?\d)[日|.]?)?)"),
|
56 |
]
|
57 |
+
self.works_key_pattern = re.compile("工作|experience|work",re.M|re.I)
|
58 |
self.job_time_patterns = re.compile('([1-2]\d{3}(\D?[01]?\d){0,2})\D?([1-2]\d{3}(\D?[01]?\d){0,2}|至今)')
|
59 |
self.edu_index = ["博士","硕士","研究生","学士","本科","大专","专科","中专","高中","初中","小学"]
|
60 |
self.edu_patterns = list(re.compile(i) for i in self.edu_index)
|
|
|
235 |
s,e = age_match.span(1)
|
236 |
elif age_match.group(2) is not None:
|
237 |
age = age_match.group(2)
|
238 |
+
s,e = age_match.span(2)
|
239 |
if age is not None:
|
240 |
return_obj['age'].append({
|
241 |
'start': index_mapper[s],
|