Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

AttributeError: 'dict_values' has no attribute 'index' #154

Open
@demetrii

Description

@demetrii

Upon running for s in sources: source, predicted = predictor.predict(s) print('\n---SOURCE----\n' + source) print('---PREDICTED----\n' + predicted)

I get the following error:
INFO:tensorflow:Restoring parameters from /content/lab/datalab/punctuation/model/punctuation-5796

AttributeError Traceback (most recent call last)
in ()
9
10 for s in sources:
---> 11 source, predicted = predictor.predict(s)
12 print('\n---SOURCE----\n' + source)
13 print('---PREDICTED----\n' + predicted)

in predict(self, content)
88 for i in indices:
89 words1[i], words1[i-1] = words1[i-1], words1[i]
---> 90 words2 = [self._word_to_id.keys()[self._word_to_id.values().index(data_x[index])] for index in range(len(puncts) - 1, len(data_x))]
91 all_words = words1 + [puncts[-1]] + words2
92 content = ' '.join(all_words)

in (.0)
88 for i in indices:
89 words1[i], words1[i-1] = words1[i-1], words1[i]
---> 90 words2 = [self._word_to_id.keys()[self._word_to_id.values().index(data_x[index])] for index in range(len(puncts) - 1, len(data_x))]
91 all_words = words1 + [puncts[-1]] + words2
92 content = ' '.join(all_words)

AttributeError: 'dict_values' object has no attribute 'index'

This is how index is defined:
words1 = [self._word_to_id.keys()[self._word_to_id.values().index(data_x[index])] for index in range(len(puncts) - 1)]

indices = [i for i, w in enumerate(words1) if w in PUNCTUATIONS]

for i in indices:

words1[i], words1[i-1] = words1[i-1], words1[i] #only line in for loop

words2 = [self._word_to_id.keys()[self._word_to_id.values().index(data_x[index])] for index in range(len(puncts) - 1, len(data_x))]
all_words = words1 + [puncts[-1]] + words2
content = ' '.join(all_words)
min_step = len(puncts)

Can anyone explain why this occurs and/or how to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions