Hi All,
Text Analysis in Python can be done with the help of so many functions. The various Types used are
List , Set etc.
Split is a function used with List. Len() function is also used.
Find some programs
1.
t='fine'
sentence='I am fine'
huparray=sentence.split()
flag=0
for word in huparray:
if word==t:
flag=1
if flag==1:
print('Positive')
Text Analysis in Python can be done with the help of so many functions. The various Types used are
List , Set etc.
Split is a function used with List. Len() function is also used.
Find some programs
1.
t='fine'
sentence='I am fine'
huparray=sentence.split()
flag=0
for word in huparray:
if word==t:
flag=1
if flag==1:
print('Positive')
2.
p='fine good great'
sentence='I am fine and great but'
shuparray=sentence.split()
phuparray=p.split();
flag=0
pcount=0
for word in shuparray:
for word1 in phuparray:
if word==word1:
pcount=pcount+1
if pcount>0:
print('Positive')
print(pcount)
3. p='fine good great'
n='bad poor slow cry'
sentence='I am fine and great but slow cry'
shuparray=sentence.split()
nhuparray=n.split();
phuparray=p.split();
flag=0
ncount=0
pcount=0
for word in shuparray:
for word1 in phuparray:
if word==word1:
pcount=pcount+1
for word in shuparray:
for word1 in nhuparray:
if word==word1:
ncount=ncount+1
if pcount>ncount:
print('Positive')
elif ncount>pcount:
print('Negative')
else:
print('Neutral')
print(ncount)
print(pcount)
4. p='fine good great'
sentence='I am fine and great but'
shuparray=sentence.split()
phuparray=p.split();
flag=0
pcount=0
plist=set(phuparray) & set(shuparray)
print(len(list(plist)))