I am having a trouble to handle the tuples in the list. Let's assume that we have list which consists of a lot of tuples in it.
simpleTag=[**('samsung', 'ADJ')**, ('user', 'NOUN'), ('huh', 'NOUN'), ('weird', 'NOUN'), (':', '.'), ('MDPai05', 'NOUN'), (':', '.'), ('Samsung', 'NOUN'), ('Electronics', 'NOUN'), ('to', 'PRT'), ('Build', 'NOUN'), ('$', '.'), ('3', 'NUM'), ('Billion', 'NUM'), ('Smartphone', 'NOUN'), ('Plant', 'NOUN'), ('in', 'ADP'), ('Vietnam', 'NOUN'), ('Why', 'NOUN'), ('not', 'ADV'), ('india', 'VERB'), ('?', '.'), ('market', 'NOUN'), ('here', 'ADV'), (':', '.'), (':', '.'), ('//t…I', 'ADJ'), ('have', 'VERB'), ('bricked', 'VERB'), ('an', 'DET'), ('android', 'ADJ'), ('samsung', 'NOUN'), ('galaxy', 'NOUN'), ('player', 'NOUN'), ('yp-g70', 'X'), ('international', 'ADJ'), ('version', 'NOUN'), (',', '.'), ('and', 'CONJ'), ('it', 'PRON'), ('is', 'VERB'), ("n't", 'ADV'), ('recognized', 'VERB'), ('by', 'ADP'), ('PC', 'NOUN'), ('an', 'DET'), ('...', '.'), (':', '.'), ('tomwicky', 'NOUN'), (':', '.'), (':', '.'), ('announces', 'NOUN'), ('partnership', 'NOUN'), ('with', 'ADP'), ('Samsung', 'NOUN'), ('for', 'ADP'), ('wallet', 'NOUN'), ('/', '.'), ('couponing', 'VERB'), ('oms14', 'NOUN'), (':', '.'), ('refrigerator', 'NOUN'), ('(', '.'), ('Spearfish', 'ADJ'), (')', 'NOUN'), ('$', '.'), ('175', 'NUM'), (':', '.'), ('refrigerator', 'NOUN'), ('samsung', 'NOUN'), ('airconditioning', 'VERB'), ('sd', 'NOUN'), ('forsale', 'NOUN'), (':', '.'), ('relaxedharry', 'NOUN'), (':', '.'), ('meanwhile', 'ADV'), ('louis', 'VERB'), ('is', 'VERB'), ('a', 'DET'), **('samsung', 'ADJ')**, ('user', 'NOUN'), ('huh', 'NOUN'), ('weird', 'NOUN'), (':', '.'), ('AmazingRoom', 'NOUN'), (':', '.'), ('if', 'ADP'), ('you', 'PRON'), ('want', 'VERB'), ('a', 'DET'), ('iPhone', 'NOUN'), ('5s', 'NUM'), ('!', '.'), ('*', 'X'), (':', '.'), ('to', 'PRT'), ('win', 'VERB'), ('a', 'DET'), ('Samsung', 'NOUN')]
What I am trying to do is replacing some tuple's values. For example in simpleTag, there are "samsung" which has two tags: 'NOUN' and 'ADJ'
What I am trying to do is replacing 'ADJ' to "NOUN'
I have tried few codes following, but I have no idea why it returns me "ADJ." Above example is only just samples of my code tagged by nltk. Please let me know what you think.
Code1:
[tupleset[:1] + ('NOUN',) for tupleset in simpleTag if word.startswith('samsung')]
Code2:
for (word,tag) in simpleTag:
if word.startswith('samsung'):
tag = 'NOUN'
Code3:
for (word,tag) in simpleTag:
if word.startswith('samsung'):
(word, tag)=(word, 'NOUN')