Vaibhav84 commited on
Commit
ffb1952
·
1 Parent(s): b076bad
Files changed (2) hide show
  1. ExtractContentsFromFile.py +20 -0
  2. app.py +17 -19
ExtractContentsFromFile.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ import PyPDF2
3
+ import docx2txt
4
+ class ExtractContentFromFile:
5
+ def ExtractDataFromFile(FileName,file):
6
+ text =''
7
+ print(text)
8
+ if FileName.endswith("pdf"):
9
+ reserve_pdf_on_memory = io.BytesIO(file)
10
+ load_pdf = PyPDF2.PdfReader(reserve_pdf_on_memory)
11
+ for page in load_pdf.pages:
12
+ text += page.extract_text()
13
+
14
+ elif FileName.endswith("doc") or FileName.endswith("docx"):
15
+ text = docx2txt.process(file)
16
+ text = text.read()
17
+
18
+ else:
19
+ text = file.decode('utf-8')
20
+ return text
app.py CHANGED
@@ -35,6 +35,7 @@ import requests
35
  from DbConnection import DbConnection
36
  from UploadFile import UploadOpenFile
37
  from SkillExtract import SkillExtractorDetails
 
38
  import os
39
  os.environ['HF_HOME'] = '/hug/cache/'
40
 
@@ -71,29 +72,15 @@ def parse_csv(df):
71
 
72
 
73
  @app.post("/uploadJobDescription/")
74
- def uploadJobDescription(file: bytes = File(...), FileName: str = "sample.pdf"):
75
- # Save file locally for processing
76
- text =''
77
- print(text)
78
- if FileName.endswith("pdf"):
79
- reserve_pdf_on_memory = io.BytesIO(file)
80
- load_pdf = PyPDF2.PdfReader(reserve_pdf_on_memory)
81
- for page in load_pdf.pages:
82
- text += page.extract_text()
83
-
84
- elif FileName.endswith("doc") or FileName.endswith("docx"):
85
- text = docx2txt.process(file)
86
- text = text.read()
87
-
88
- else:
89
- text = file.decode('utf-8')
90
-
91
  returnID = UploadOpenFile.uploadFile(text,FileName,db_params)
92
  returnSkills = SkillExtractorDetails.SkillExtract(db_params,skill_extractor,returnID)
93
  details = returnSkills.split('@')
94
  data = {'Data':['Required Skills', 'Soft Skills', 'Good to have Skills'], 'Values':[details[0], details[1], details[2]]}
95
  df = pd.DataFrame(data)
96
  return parse_csv(df)
 
97
  @app.get("/AllProfileMatchResults")
98
  def AllProfileMatchResults():
99
  dbQuery = "select * from profilematch"
@@ -121,5 +108,16 @@ def ExtractSkillsByJobID(skill_data: SkillDetails):
121
  skill_data.goodToHaveSkills = details[1]
122
  return skill_data
123
 
124
-
125
- #return JSONResponse(content={"message": "Here's your interdimensional portal." , "mes1":"data2"})
 
 
 
 
 
 
 
 
 
 
 
 
35
  from DbConnection import DbConnection
36
  from UploadFile import UploadOpenFile
37
  from SkillExtract import SkillExtractorDetails
38
+ from ExtractContentsFromFile import ExtractContentFromFile
39
  import os
40
  os.environ['HF_HOME'] = '/hug/cache/'
41
 
 
72
 
73
 
74
  @app.post("/uploadJobDescription/")
75
+ def uploadJobDescription(file: bytes = File(...), FileName: str = "sample.pdf"):
76
+ text= ExtractContentFromFile.ExtractDataFromFile(FileName,file)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  returnID = UploadOpenFile.uploadFile(text,FileName,db_params)
78
  returnSkills = SkillExtractorDetails.SkillExtract(db_params,skill_extractor,returnID)
79
  details = returnSkills.split('@')
80
  data = {'Data':['Required Skills', 'Soft Skills', 'Good to have Skills'], 'Values':[details[0], details[1], details[2]]}
81
  df = pd.DataFrame(data)
82
  return parse_csv(df)
83
+
84
  @app.get("/AllProfileMatchResults")
85
  def AllProfileMatchResults():
86
  dbQuery = "select * from profilematch"
 
108
  skill_data.goodToHaveSkills = details[1]
109
  return skill_data
110
 
111
+ @app.post("/RemoveSkillsByName/")
112
+ def RemoveSkills(SkillName : str):
113
+ conn = psycopg2.connect(**db_params)
114
+ cursor = conn.cursor()
115
+ SkillName = data.split(':')[1]
116
+ print("Removing Skills " + SkillName)
117
+ query = "update skillmaster set weightage = 0 where skilldetails = (%s)"
118
+ params = (SkillName,)
119
+ cursor.execute(query, params)
120
+ conn.commit()
121
+ cursor.close()
122
+ conn.close()
123
+ #return JSONResponse(content={"message": "Here's your interdimensional portal." , "mes1":"data2"})