original_docstring: Creates an image with a word cloud based on the initialized word list
docstring: Creates an image with a word cloud based on the initialized word list
docstring_tokens: Creates an image with a word cloud based on the initialized word list
code: def create_word_cloud(self):
          """Creates an image with a word cloud based on the initialized word list"""
  
          # most frequent word goes in the center
          self.words[0].set_coordinates(self.get_center_position(self.words[0]))
          self.draw_word(self.words[0])
  
          # rest of the words
          # algorithm: in descending order (from most frequent to least), randomly generate a position
          # for the word, check if it doesn't intersect with any of the previous words and place it
          # todo: create a more efficient algorithm, right now it's brute force, with an emphasis on brute
          for i in range(1, len(self.words)):
              # todo: DRY
              # might start at the edge of the screen but get cut off by the image limits
              rand_xy = random.randrange(self.canv_x), random.randrange(self.canv_y)
              self.words[i].set_coordinates(rand_xy)
              # todo: this could be  improved with dynamic programming
              while self.is_touching_edges(self.words[i]) or \
                      WordCloud.word_intersects_with_the_rest(self.words[i], self.words[0:i]):
                  rand_xy = random.randrange(self.canv_x), random.randrange(self.canv_y)
                  self.words[i].set_coordinates(rand_xy)
              self.draw_word(self.words[i])
code_tokens: def create_word_cloud ( self ) : self . words [ 0 ] . set_coordinates ( self . get_center_position ( self . words [ 0 ] ) ) self . draw_word ( self . words [ 0 ] ) for i in range ( 1 , len ( self . words ) ) : rand_xy = random . randrange ( self . canv_x ) , random . randrange ( self . canv_y ) self . words [ i ] . set_coordinates ( rand_xy ) while self . is_touching_edges ( self . words [ i ] ) or WordCloud . word_intersects_with_the_rest ( self . words [ i ] , self . words [ 0 : i ] ) : rand_xy = random . randrange ( self . canv_x ) , random . randrange ( self . canv_y ) self . words [ i ] . set_coordinates ( rand_xy ) self . draw_word ( self . words [ i ] )
short_docstring: Creates an image with a word cloud based on the initialized word list
short_docstring_tokens: Creates an image with a word cloud based on the initialized word list
comment: """Creates an image with a word cloud based on the initialized word list"""$SEP$# most frequent word goes in the center$SEP$# rest of the words$SEP$# algorithm: in descending order (from most frequent to least), randomly generate a position$SEP$# for the word, check if it doesn't intersect with any of the previous words and place it$SEP$# todo: create a more efficient algorithm, right now it's brute force, with an emphasis on brute$SEP$# todo: DRY$SEP$# might start at the edge of the screen but get cut off by the image limits$SEP$# todo: this could be  improved with dynamic programming