Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- paragraph='mobile platform is good and a battery is not bad and battery good and screen is not good'
- words=paragraph.split()
- gwords='super','superb','excellent','smooth','awesome','pro','best','rocking','perfect','satisfies','fast','smart','good','average','nice','fine']
- bwords=['bad','worse','worst','con','bullshit','pathetic','worst','floppy','irritating']
- k=0
- gcount=0
- bcount=0
- pa=""
- gc=0
- bc=0
- parts=['battery','screen']
- swapwords=['not','no']
- for p in parts:
- gcount=0
- bcount=0
- i=0
- for w in words:
- if p==w:
- length=len(words)
- part_pos=i
- l=0
- m=0
- for j in range(part_pos,length):
- if l==0 and m==0:
- for g in gwords:
- if words[j]==g:
- l=l+1
- for g in bwords:
- if words[j]==g:
- m=m+1
- for g in swapwords:
- if words[j]==g:
- for g in gwords:
- if words[j+1]==g:
- m=m+1
- for g in bwords:
- if words[j+1]==g:
- l=l+1
- gcount=gcount+l
- bcount=bcount+m
- i=i+1
- print p
- print gcount
- print bcount
- i=0
- for wo in words:
- flag=0
- for w in gwords:
- if w==wo:
- for n in swapwords:
- if i==1:
- if words[i-1]==n:
- bc=bc+1
- flag=1
- break
- else:
- gc=gc+1
- flag=1
- break
- elif i==2:
- if words[i-1]==n or words[i-2]==n:
- bc=bc+1
- flag=1
- break
- else:
- gc=gc+1
- flag=1
- break
- elif i>=3:
- if words[i-1]==n or words[i-2]==n or words[i-3]==n:
- bc=bc+1
- flag=1
- break
- else:
- gc=gc+1
- flag=1
- break
- if flag==0:
- for w in bwords:
- if w==wo:
- for n in swapwords:
- if i==1:
- if words[i-1]==n:
- gc=gc+1
- break
- else:
- bc=bc+1
- break
- elif i==2:
- if words[i-1]==n or words[i-2]==n:
- gc=gc+1
- break
- else:
- bc=bc+1
- break
- elif i>=3:
- if words[i-1]==n or words[i-2]==n or words[i-3]==n:
- gc=gc+1
- break
- else:
- bc=bc+1
- break
- i=i+1
- print gc
- print bc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement