text Q
Htmlfile
<selecti
d=”employee-l
ist”>
<optionvalue=””>Sel
ectanemployee</option>
<!—Populatethi
sdropdownwithemployeenamesusingPHP
</select>
<divid=”employee-detai
ls”>
<!—Employeedetail
swillbedisplayedhere
Phpfileasempdetails.php
<?php //Establi shdatabaseconnection $conn=pg_connect(“host=l password=password”); ocalhostdbname=database_nameuser=username If(!$conn){ Die(‘ Connectionfail ed:‘.pg_last_error()); } //GettheselectedemployeenamefromAJAXrequest $employeeName=$_POST[‘employeeName’]; //QuerytheEMPtableforthedetailsoftheselectedemployee $sql=“SELECT*FROMEMPWHEREename=‘$employeeName’”; $result=pg_query($conn,$sql ); If(pg_num_rows($resul t)>0){ //BuildaJSONobjectwithemployeedetails $employee=pg_fetch_assoc($resul $response=array( ‘ename’=>$employee[‘ ename’], ‘designati on’=>$employee[‘ t); designati ‘salary’=>$empl oyee[‘ salary’ ); ] Echojson_encode($response); }else{ Echo“Employeenotfound”; } //Closedatabaseconnection Pg_close($conn); ?>Importre
Fromnltk.tokeni
zeimportsent_tokeni
Fromsklearn.feature_extracti
Fromsklearn.metri
cs.pairwi
#Texttosummarize
Text=“Helloall
alcharactersanddigi
ts.Generate
onprocess.Q.
ze
on.texti
mportTfidfVectori
seimportcosine_si
milari
ty
zer
,WelcometoPythonProgrammingAcademy.PythonProgrammingAcademyis
aniceplatformtolearnnewprogrammingskill
s.Itisdiffi
culttogetenrol
ledinthisAcademy.”
#Preprocessthetexttoremovespecialcharactersanddi
gits
Preprocessed_text=re.
sub(r’
[^a-zA
Z\s]’
,‘’
,text)
#Tokenizethepreprocessedtexti
ntosentences
Sentences=sent_tokeni
ze(preprocessed_text)
#CalculatetheimportancescoreofeachsentenceusingTF-IDF
Vectorizer=Tfi
dfVectori
zer()
Tfidf_matri
x=vectorizer.
fit_t
Similari
ty_matri
ransform(sentences)
x=cosine_similari
ty(tfi
df_matrix)
#SelecttopNsentencesbasedontheirimportancescore
N=2
Top_sentences=sorted(range(l
en(simil
arity_matri
N:]
x[-1]
)),key=l
ambdai:similari
#Concatenatethetopsentencestoformthesummary
Summary=‘’
Foriintop_sentences:
Summary+=sentences[i]+‘‘
Print(summary