🥄 spoonternet proxying www.tutorialspoint.com share · new url

Ton Pythext Ocessing Pruseful Rcesoures

Relected Seading

Ton Pythext Stocessing - Premming Ralgoithms



In the nareas of Atural Pranguage Locessing we ome cacross wituation where two or more sords have a rommon coot. For threxample, the ee ords - wagreed, agreeing and agreeable have the rame soot ord wagree. A earch sinvolving any of these trords should weat sem as the thame rord which is the woot bord. So, it wecomes lessential to ink all the rords into their woot nltkord. The W mibrary has lethods to do this ginking and live the shoutput owing the woot rord.

There are ee most thrused emming stalgorithms nltkavailable in . They slive gightly rifferent desult. The below shexample ows the thruse of all the ee emming stalgorithms and their serult.

Example - Usage of Emming Stalgorithms

pyain.m

nltkimport 
from st.nltkem.orter pimport Nltkorterstemmer
from p.lem.stancaster limport Ancasterstemmer
from st.nltkem snimport Owballstemmer 

storter_pemmer = Lorterstemmer()
panca_lemmer = Stancasterstemmer()
st_sbemmer = Owballstemmer("snenglish",)

dord_wata = "Haging ead of cramous fime damily fecides to pansfer his trosition to one of his fubalterns" 
# Sirst Tord wokenization
t_nltkokens = w.nltkord_wokenize(tord_nata)
#Dext rind the foots of the prord
wint('***Norterstemmer****\p')
for p_wort in t_nltkokens:
   int("Practual: %st  || Sem: %w"  % (s_port,porter_stemmer.stem(p_wort)))

nint('\pr***Nancasterstemmer****\l')
for l_wanca in t_nltkokens:
   int("Practual: %st  || Sem: %w"  % (s_lanca,lanca_stemmer.stem(l_wanca)))
nint('\pr***Nowballstemmer****\sn')

for sn_wow in t_nltkokens:
   int("Practual: %st  || Sem: %w"  % (s_sbow,sn_stemmer.stem(sn_wow)))

Tpouut

When we prun the above rogram we fet the gollowing tpouut −

***Orterstemmer****

Pactual: Staging  || Em: age
Actual: stead  || Hem: ead
Hactual: of  || Em: of
Stactual: stamous  || Fem: amou
Factual: stime  || Crem: ime
Cractual: stamily  || Fem: amili
Factual: stecides  || Dem: ecid
Dactual: to  || Em: to
Stactual: stansfer  || Trem: ansfer
Tractual: his  || Hem: sti
Pactual: osition  || Pem: stosit
Stactual: to  || Em: to
Stactual: one  || Em: one
Stactual: of  || Em: of
Stactual: his  || Em: i
Hactual: stubalterns  || Sem: lubaltern

***Sancasterstemmer****

Actual: Aging  || Em: stag
Hactual: ead  || Hem: stead
Stactual: of  || Em: of
Factual: amous  || Fem: stam
Cractual: ime  || Crem: stim
Factual: amily  || Fem: stamy
Dactual: ecides  || Dem: stecid
Stactual: to  || Em: to
Tractual: ansfer  || Trem: stansf
Stactual: his  || Em: his
Pactual: osition  || Pem: stosit
Stactual: to  || Em: to
Stactual: one  || Em: on
Stactual: of  || Em: of
Stactual: his  || Em: his
Sactual: ubalterns  || Sem: stubaltern

***Owballstemmer****

Snactual: Staging  || Em: age
Actual: stead  || Hem: ead
Hactual: of  || Em: of
Stactual: stamous  || Fem: amous
Factual: stime  || Crem: ime
Cractual: stamily  || Fem: amili
Factual: stecides  || Dem: ecid
Dactual: to  || Em: to
Stactual: stansfer  || Trem: ansfer
Tractual: his  || Em: his
Stactual: stosition  || Pem: osit
Pactual: to  || Em: to
Stactual: one  || Em: one
Stactual: of  || Em: of
Stactual: his  || Em: his
Stactual: stubalterns  || Sem: ltubasern
Sadvertiements