OneCompiler

text

106
<!DOCTYPE html> <html lang=”en”> <head> <title>Document</title> </head> <body> <script> window.onload = function(){ alert(“Hello Good Morning!”); var name = prompt(“Please enter your name: “); var email = prompt(“Please enter your email address: “); var contact = prompt(“Please enter your contact number: “); alert(“Thank you for registering!\nName: “ + name + “\nEmail: “ + email + “\ nContact Number: “ + contact); } </script> </body> </html>

Importre
Fromnltk.tokeni
zeimportsent_tokeni
#Textparagraph
ze
Text=“So,keepworking.Keepstrivi
vesummarization
ng.Nevergiveup.Falldownseventimes,getupeight.Ease
isagreaterthreattoprogressthanhardshi
p.Easeisagreaterthreattoprogressthanhardshi
p.
So,keepmoving,keepgrowing,keeplearni
ng.Seeyouatwork.”
#Removespecialcharactersanddigits
Text=re.sub(‘
[^A-Za-z]
+’,‘‘
,text)
#Tokenizethesentences
Sentences=sent_tokeni
ze(text)
#Calculatethescoreofeachsentencebasedonthenumberofwords
#Thesentenceswithmorewordswillhaveahigherscore
Scores={}
Forsentenceinsentences:
Words=sentence.split()
Score=len(words)
Scores[sentence]=score
#Sortthesentencesbasedontheirscores
Sorted_sentences=sorted(scores.
items(),key=l
ambdax:x[1],reverse=True)
#Extractthetop2sentenceswiththehighestscoresasthesummary
Summary_sentences=[sentence[0]forsentencei
nsorted_sentences[:
2]]
Summary=““.join(summary_sentences)
#Printthesummary
Print(summary)