Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

par_eda =1,error #4

Open
jxy-001 opened this issue Aug 30, 2019 · 3 comments
Open

par_eda =1,error #4

jxy-001 opened this issue Aug 30, 2019 · 3 comments

Comments

@jxy-001
Copy link

jxy-001 commented Aug 30, 2019

if par_eda == 1: # use eda to operate sentences when par_eda is true
for i in range(len(dat_plus['title_text'])):
if i%6 == 1:
dat_plus['title_text'][i] = copy.deepcopy(eda_text(dat_plus['title_text'][i]))
dat_plus['title_text'][i] = "".join(dat_plus['title_text'][i])


TypeError Traceback (most recent call last)
in
2 for i in range(len(dat_plus['title_text'])):
3 if i%6 == 1:
----> 4 dat_plus['title_text'][i] = copy.deepcopy(eda_text(dat_plus['title_text'][i]))
5 dat_plus['title_text'][i] = "".join(dat_plus['title_text'][i])

in eda_text(text)
23 if len(zz) <= 500:
24 #print(len(zz))
---> 25 tmp_text = aug_text(tmp_text)
26 # conbine prior 3 sentences and rest sentences
27 for j in range(len(text)-3):

in aug_text(text)
1 def aug_text(text):
----> 2 text = aug.augment(text)
3 return(text)

/home/user5/Desktop/BERT-FAKE-OR-TRUE/nlpaug/flow/sequential.py in augment(self, data)
36 augmented_data = data[:]
37 for aug in self:
---> 38 augmented_data = aug.augment(augmented_data)
39
40 results.append(augmented_data)

/home/user5/Desktop/BERT-FAKE-OR-TRUE/nlpaug/base_augmenter.py in augment(self, data)
71 return self.insert(data)
72 elif self.action == Action.SUBSTITUTE:
---> 73 return self.substitute(data)
74 elif self.action == Action.SWAP:
75 return self.swap(data)

/home/user5/Desktop/BERT-FAKE-OR-TRUE/nlpaug/augmenter/word/bert.py in substitute(self, data)
98 for aug_idx in aug_idxes[:1]:
99 original_word = results[aug_idx]
--> 100 candidate_words = self.model.predict(results, original_word, top_n=self.aug_n)
101 substitute_word = self.sample(candidate_words, 1)[0]
102

/home/user5/Desktop/BERT-FAKE-OR-TRUE/nlpaug/model/lang_models/bert.py in predict(self, input_tokens, target_word, top_n)
44 top_score_idx = target_idx
45 for _ in range(100):
---> 46 predictions[0, target_pos, top_score_idx] = -9999
47 top_score_idx = torch.argmax(predictions[0, target_pos]).item()
48 top_score_token = self.tokenizer.convert_ids_to_tokens([top_score_idx])[0]

TypeError: 'tuple' object does not support item assignmen

@EthanWng97
Copy link
Owner

I havent meet this problem before. Print dat_plus and its type.
Maybe u can rerun the cells above to solve this problem.

@jxy-001
Copy link
Author

jxy-001 commented Aug 30, 2019

the type is str
so how did you solve the problem?Rerun is useless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants