Jump to content
Fórum Script Brasil
  • 0

python 'pycharm'


Question

beleza meus colegas ? estou precisando de ajuda, eu sou novato na programação ,estou com um problema com o pycharm.

instalei o python  3.7.3, pycharm 2019.1.1 (Edu) e o pycharm 2019 1.3(Professional edition) ambos dão o mesmo erro. 

Uso windows 10.

class BagOfWords:
        def __int__(self):
                self.vocab = []

        def build_vocab(self, sentences):
                for sentence in sentences:
                        for word in sentence.split(' '):
                                if word not in self.vocab:
                                        self.vocab.append(word)

                self.vocab.sort()
                print(self.vocab)

        def toarray(self, sentence):
                words = sentence.split(' ')
                print(words)


inputs = ['I like it', 'I hate it', ' that was', 'that was bad']

bow = BagOfWords()
bow.build_vocab(inputs)

 código do erro:. AttributeError: 'BagOfWords' object has no attribute 'vocab'

por que da esse erro?

 

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing


  • Forum Statistics

    • Total Topics
      148680
    • Total Posts
      644502
×
×
  • Create New...