-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructureLabelsPrediction.py
More file actions
35 lines (30 loc) · 1.58 KB
/
StructureLabelsPrediction.py
File metadata and controls
35 lines (30 loc) · 1.58 KB
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
import joblib
import logging
import json
class StructureLabelsPrediction(object):
def __init__(self, df):
logging.basicConfig(level=logging.DEBUG, filename='log.log', format='%(asctime)s %(levelname)s:%(message)s')
logging.debug("StructureLabelsPrediction is running")
page_names = ['наличие целей', 'наличие задач', 'наличие во введение цели и задач',
'соответствие темы работы направлению', 'соответствие введения заданной теме',
'наличие актуальности во введении',
'наличие обоснования актуальности во введении']
lst_page_names = ['page0', 'page1', 'page2', 'page3', 'page4', 'page5', 'page6']
self.dict_page_names = {k: v for k, v in zip(lst_page_names, page_names)}
def get_results(self, df):
'''
:param df:
:return:
'''
logging.debug("StructureLabelsPrediction.get_results is run")
main_preproc_text = df['main_preproc_text']
introduction = df['main_preproc_text']
dict_results = joblib.load('models/dict_results.jbl')
result = {}
for k in dict_results:
model = dict_results[k].get('model_best')
result[k] = {
'predicted_main_preproc_text': model.predict(main_preproc_text)[0],
'predicted_introduction': model.predict(introduction)[0],
}
return result