def __get_basic_details(self): name = utils.extract_name(self.__resume) email = utils.extract_email(self.__text) mobile = utils.extract_mobile_number(self.__text) skills = utils.extract_skills(self.__nlp, self.__noun_chunks) edu = utils.extract_education( [sent.string.strip() for sent in self.__nlp.sents]) experience = utils.extract_experience(self.__text) entities = utils.extract_entity_sections(self.__text_raw) self.__details['name'] = name self.__details['email'] = email self.__details['mobile_number'] = mobile self.__details['skills'] = skills # self.__details['education'] = entities['education'] self.__details['education'] = edu self.__details['experience'] = experience try: self.__details['competencies'] = utils.extract_competencies( self.__text_raw, entities['experience']) self.__details[ 'measurable_results'] = utils.extract_measurable_results( self.__text_raw, entities['experience']) except KeyError: self.__details['competencies'] = [] self.__details['measurable_results'] = [] return
def replace_array_init(kwargs): """ Replace a call to zeros, ones, or empty with a specialized node. Only C ordering is supported at this time. "like" is unsupported, because it requires handling alternative implementations of the __array__ protocol. """ order = extract_name(kwargs["order"]) like = extract_name(kwargs["like"]) if order != "C": msg = "Only C ordering is supported at this time." raise CompilerError(msg) elif like is not None: msg = "Numpy array initialization with 'like' parameter set is not yet supported." raise CompilerError(msg) dtype = type_from_numpy_type(kwargs["dtype"]) shape = tuple(wrap_input(s) for s in kwargs["shape"]) fill_value = ir.One return ir.ArrayInitSpec(shape, dtype, fill_value)
def codegen(build_dir, funcs, symbols, modname): file_path = pathlib.Path(build_dir).joinpath(f"{modname}Module.c") printer = Emitter(file_path) mod_builder = ModuleCodeGen(modname, printer) bp_gen = BoilerplateWriter(printer, modname) sys_headers = ("ndarraytypes.h.", ) func_lookup = {} methods = [] # get return type with printer.flush_on_exit(): bp_gen.gen_source_top(sys_headers) # These are just way too difficult to read as inline ternary ops, and their precedence # flips completely when used with intrinsics, making this seem like a sensible option with printer.ifndef_directive("min"): printer.print_line("#define min(x,y) (x < y ? x : y)") with printer.ifndef_directive("max"): printer.print_line("#define max(x,y) (x > y ? x : y)") with printer.ifndef_directive("select"): printer.print_line( "#def select(x, y, predicate) (predicate ? x : y)") printer.blank_lines(count=2) bp_gen.gen_module_init() printer.blank_lines(count=2) for func in funcs: basename = func.name func_symbols = symbols.get(basename) mangled_name, arg_types = make_func_sig(func, func_symbols, modname) # return_type = get_return_type(func) # Generate python wrapper wrapper_name = f"{modname}_{basename}" func_lookup[basename] = (mangled_name, arg_types) # return_type = get_ctype_name(return_type) return_type = "void" # temporary standin.. arg_names = (extract_name(arg) for arg in func.args) arg_str = ", ".join(f"{type_} {arg}" for (type_, arg) in zip(arg_types, arg_names)) sig = f"{return_type} {mangled_name}({arg_str})" printer.print_line(sig) with printer.curly_braces(): # print decls decls = ", ".join(f"{get_ctype_name(sym.type_)} {sym.name}" for sym in func_symbols.source_locals) if decls: # skip if no local variables declared in source printer.print_line(f"{decls};") mod_builder(func.body, func_symbols) methods.append((basename, mangled_name)) printer.blank_lines(count=2) bp_gen.gen_method_table(methods) printer.blank_lines(count=2) bp_gen.gen_module_def()
def replace_call(node: ir.Call): """ AST level replacement for functions that are specialized internally. """ func_name = extract_name(node) replacer = replacers.get(func_name) if replacer is None: if func_name.startswith("numpy."): msg = f"Invalid or unsupported numpy call: {func_name}." raise CompilerError(msg) return node # Todo: expand this for (any,all later # Todo: Some of the builtin calls follow strange overloading conventions # so they had to be separated. I may rework this further, as I hate type checks. repl = replacer(node) return repl
def make_unique_name_like(self, name, type_): """ This is used to add a unique typed temporary variable name. """ prefix_ = extract_name(name) if type_ is None: msg = f"Failed to retrieve a type for name {prefix_}." raise CompilerError(msg) gen = self._get_name_mangler(prefix_) name = f"{prefix_}_{next(gen)}" while self.declares(name): name = f"{prefix_}_{next(gen)}" sym = symbol(name, type_, is_arg=False, is_source_name=False) self.symbols[name] = sym # The input name may require mangling for uniqueness. # Return the name as it is registered. return wrap_input(name)
def __get_basic_details(self): name = utils.extract_name(self.__nlp, matcher=self.__matcher) email = utils.extract_email(self.__text) mobile = utils.extract_mobile_number(self.__text) skills = utils.extract_skills(self.__nlp, self.__noun_chunks) edu = utils.extract_education([sent.string.strip() for sent in self.__nlp.sents]) entities = utils.extract_entity_sections_grad(self.__text_raw) self.__details['name'] = name self.__details['email'] = email self.__details['mobile_number'] = mobile self.__details['skills'] = skills self.__details['education'] = edu try: self.__details['experience'] = entities['experience'] except KeyError: self.__details['total_experience'] = 0 self.__details['no_of_pages'] = utils.get_number_of_pages(self.__resume) return
def make_func_sig(func: ir.Function, syms: symbol_table, modname): # maintain argument order args = tuple(syms.lookup(arg) for arg in func.args) arg_names = [] for arg in func.args: sym = syms.lookup(arg) name = sym.name type_ = get_ctype_name(sym.type_) arg_names.append(f"{type_} {name}") types = [syms.check_type(arg) for arg in func.args] basename = extract_name(func.name) mangled_name = mangle_func_name(basename, types, modname) formatted_args = [] for type_, arg in zip(types, args): type_str = get_ctype_name(type_) if isinstance(arg.type_, (ir.ArrayType, ir.ArrayArg)): type_str = f"{type_str}*" formatted_args.append(type_str) return mangled_name, formatted_args
def parse_cv(): if 'file' not in request.files: flash('No file part') file = request.files['file'] if file and allowed_file(file.filename): file.save(os.path.join(app.config['UPLOAD_FOLDER'], 'tmp.pdf')) file_path = 'upload/tmp.pdf' text = '' for page in extract_text_from_pdf(file_path): text += ' ' + page name = extract_name(text) phone = extract_mobile_numbers(text) email = extract_emails(text) skills = extract_skills(text) return jsonify(name=name, phones=phone, emails=email, skills=skills)
def __get_basic_details(self): name = utils.extract_name(self.__nlp, matcher=self.__matcher) full_name = utils.get_first_name(name, self.__nlp) gender = utils.get_gender(self.__nlp) maritial_status = utils.get_maritial_status(self.__nlp) passport_number = utils.get_passport_number(self.__text_raw) date_of_birth = utils.extract_date_of_birth(self.__nlp, self.__text) email = utils.extract_email(self.__text) mobile = utils.extract_mobile_number(self.__text) skills = utils.extract_skills(self.__nlp, self.__noun_chunks) nationality = utils.get_nationality(self.__nlp) languages = utils.extract_language(self.__nlp, self.__noun_chunks, self.__languages_file) num_of_companies = utils.extract_no_of_companies_worked_for( self.__nlp, self.__noun_chunks, self.__companies_file) hobbies = utils.extract_hobbies(self.__nlp, self.__noun_chunks, self.__hobbies_file) edu = utils.extract_education( [sent.string.strip() for sent in self.__nlp.sents], self.__nlp, self.__resume, date_of_birth) entities = utils.extract_entity_sections_grad(self.__text_raw) address = utils.extract_address(self.__nlp, self.__noun_chunks) states = utils.extract_state(self.__nlp, self.__noun_chunks) pincodes = utils.extract_pin(self.__nlp, self.__noun_chunks) cities = utils.extract_cities(self.__nlp, self.__noun_chunks) experience = utils.extract_experience_exceptional( self.__nlp, self.__noun_chunks) self.__details['name'] = name self.__details['full_name'] = full_name self.__details['gender'] = gender self.__details['maritial_status'] = maritial_status self.__details['passport_number'] = passport_number self.__details['date_of_birth'] = date_of_birth self.__details['email'] = email self.__details['mobile_number'] = mobile self.__details['skills'] = skills self.__details['nationality'] = nationality self.__details['languages'] = languages self.__details['No. of companies'] = num_of_companies self.__details['hobbies'] = hobbies self.__details['education'] = edu self.__details['address'] = address self.__details['state'] = states self.__details['pin'] = pincodes self.__details['city'] = cities self.__details['experience'] = experience try: #self.__details['experience'] = entities['experience'] try: self.__details['competencies'] = 'none' utils.extract_competencies(self.__text_raw, entities['experience']) self.__details['measurable_results'] = 'none' utils.extract_measurable_results(self.__text_raw, entities['experience']) self.__details['total_experience'] = round( utils.get_total_experience(entities['experience']) / 12, 2) except KeyError: self.__details['competencies'] = {} self.__details['measurable_results'] = {} self.__details['total_experience'] = 0 except KeyError: self.__details['competencies'] = {} self.__details['measurable_results'] = {} self.__details['total_experience'] = 0 self.__details['no_of_pages'] = { } #utils.get_number_of_pages(self.__resume) #comented by vishal sharma 11/8/2019 ''' if len( self.__details['city'])>1: cities = utils.extract_cities_exceptional(self.__nlp, self.__noun_chunks,self.__details['city']) self.__details['city'] = cities ''' if len(self.__details['pin']) > 1: pincodes = utils.extract_pin_exceptional(self.__nlp, self.__noun_chunks, self.__details['pin']) self.__details['pin'] = pincodes return
def lookup(self, name): name = extract_name(name) sym = self.symbols.get(name) return sym
def declares(self, name): name = extract_name(name) return name in self.symbols
def check_type(self, name): name = extract_name(name) return self.symbols[name].type_
async def auth(sid, sent_data): print(f"auth({sid}, {sent_data})") name = utils.extract_name(sent_data) await data.user_auth(sid, name=name)
def __get_basic_details(self): custom_entities = utils.extract_entities_wih_custom_model( self.__custom_nlp) name = utils.extract_name(self.__nlp, matcher=self.__matcher) email = utils.extract_email(self.__text) mobile = utils.extract_mobile_number(self.__text) skills = utils.extract_skills(self.__nlp, self.__noun_chunks, self.__skills_file) edu = utils.extract_education( [sent.string.strip() for sent in self.__nlp.sents]) entities = utils.extract_entity_sections_grad(self.__text_raw) print(name) # extract name try: self.__details['name'] = custom_entities['Name'][0] except (IndexError, KeyError): self.__details['name'] = name #extract email self.__details['email'] = email # extract mobile number self.__details['mobile_number'] = mobile # extract skills self.__details['skills'] = skills # extract college name try: self.__details['college_name'] = entities['College Name'] except KeyError: pass # extract education Degree try: self.__details['degree'] = custom_entities['Degree'] except KeyError: pass # extract designation try: self.__details['designation'] = custom_entities['Designation'] except KeyError: pass # extract company names try: self.__details['company_names'] = custom_entities[ 'Companies worked at'] except KeyError: pass try: self.__details['experience'] = entities['experience'] try: self.__details['total_experience'] = round( utils.get_total_experience(entities['experience']) / 12, 2) except KeyError: self.__details['total_experience'] = 0 except KeyError: self.__details['total_experience'] = 0 self.__details['no_of_pages'] = utils.get_number_of_pages( self.__resume) return