Этот код является частью моего проекта Django, моя задача - найти название компании из парсинга описания вакансии, но я не могу получить название компании?
from .CleanJdTextData import Cleaned_Text, ReadModule from resume_app.Config_Reader import Config_Dict from jd_app.Designation_Extract import Designation_Extract
nlp_Company_Module = ReadModule(Config_Dict['company_aliases_resume_parsing']) nlp_designation_module = ReadModule(Config_Dict['designation_saveLoc'])
добавлено
class CompanyExtract():
def __init__(self, cleaned_data, nlp_cn):
self.cleaned_data = cleaned_data
self.nlp_cn = nlp_cn
def company_extract(self):
company_designation_dict = dict()
if all([self.cleaned_data, isinstance(self.cleaned_data, tuple)]):
try:
area_to_search = self.cleaned_data[:10]
except:
area_to_search = self.cleaned_data
area_to_search = self.cleaned_data
for index, data in enumerate(area_to_search):
# for data in area_to_search:
company_data = self.apply_Nlp_On_Data(data)
if any([company_data]):
company_designation_dict.update({'company_name':company_data})
designation = Designation_Extract(self.cleaned_data, nlp_designation_module()).extract_designation(index)
if any([designation]):
company_designation_dict.update({'designation':designation})
return company_designation_dict
def lemma_Add_In_data(self, str_data):
lemma_add = ' '.join([x.lemma_ if x.text != "limited" else x.text for x in self.nlp_cn(str_data)])
data = [str_data, lemma_add] if lemma_add != str_data else [str_data]
if any([data]):
return data
def replace_Pvt_Ltd(self, str_data):
if all([str_data, isinstance(str_data, str)]):
replace_dict = {"pvt": "private", "ltd": "limited", "co":"company", "inc":"incorporated", "corp": "corporation"}
data = ' '.join([replace_dict[x] if x in replace_dict.keys() else x for x in str_data.split()])
if any([data]):
return self.lemma_Add_In_data(data)
def apply_Nlp_On_Data(self, str_data):
if all([str_data, isinstance(str_data, str)]):
replace_pvt_ltd_ = self.replace_Pvt_Ltd(str_data)
if any([replace_pvt_ltd_]):
for company_name in replace_pvt_ltd_:
doc = self.nlp_cn(company_name)
company_name_s = [x.text.title() for x in doc]
if any([company_name_s]):
return company_name_s[0]
class ExtractCompanyName: def init(self, text_data): self.text_data = text_data
def extract_company_name(self):
if all([self.text_data, isinstance(self.text_data, tuple)]):
company_designation_dict = dict()
global obj_Of_clean_Data
obj_Of_clean_Data = Cleaned_Text(self.text_data, ['+', '&'])
company_designation_dict = CompanyExtract(obj_Of_clean_Data(), nlp_Company_Module()).company_extract()
if any([company_designation_dict]):
return company_designation_dict