Creates a word cloud using the input.
           Input can be a file, directory, or text.
           Set exclude_words to true if you want to eliminate words that only occur once.
321163
def smart_cloud(self,input,max_text_size=72,min_text_size=12,exclude_words = True):
        ''''''
        self.exclude_words = exclude_words
        if isdir(input):
            self.directory_cloud(input,max_text_size,min_text_size)
        elif isfile(input):
            text = read_file(input)
            self.text_cloud(text,max_text_size,min_text_size)
        elif isinstance(input, basestring):
            self.text_cloud(input,max_text_size,min_text_size)
        else:
            print 'Input type not supported.'
            print 'Supported types: String, Directory, .txt file'
723451
@Override
	public FileInputSplit[] createInputSplits(int minNumSplits) throws IOException {
		int numAvroFiles = 0;
		final Path path = this.filePath;
		// get all the files that are involved in the splits
		final FileSystem fs = path.getFileSystem();
		final FileStatus pathFile = fs.getFileStatus(path);

		if (!acceptFile(pathFile)) {
			throw new IOException("The given file does not pass the file-filter");
		}
		if (pathFile.isDir()) {
			// input is directory. list all contained files
			final FileStatus[] dir = fs.listStatus(path);
			for (int i = 0; i < dir.length; i++) {
				if (!dir[i].isDir() && acceptFile(dir[i])) {
					numAvroFiles++;
				}
			}
		} else {
			numAvroFiles = 1;
		}
		return super.createInputSplits(numAvroFiles);
	}
881013
def wordcount(text):
    ''''''
    bannedwords = read_file('stopwords.txt')
    wordcount = {}
    separated = separate(text)
    for word in separated:
        if word not in bannedwords:
            if not wordcount.has_key(word):
                wordcount[word] = 1
            else:
                wordcount[word] += 1
    return wordcount
998160
def file_create(filename, settings):
        
        if len(settings) != 1:
            raise ValueError("Settings must only contain one item with key "
                             "'content'.")
        for k, v in settings.items():
            if k == "content":
                with open(filename, 'w') as f:
                    f.write(v)
780247
def _create_word_graph_file(name, file_storage, word_set):
    """"""
    word_graph_file = file_storage.create_file(name)
    spelling.wordlist_to_graph_file(sorted(list(word_set)),
                                    word_graph_file)
    return copy_to_ram(file_storage).open_file(name)
832831
def create_input_for_numbered_sequences(headerDir, sourceDir, containers, maxElements):
    """"""
    # Create additional container-list without "map".
    containersWithoutMap = containers[:]
    try:
        containersWithoutMap.remove('map')
    except ValueError:
        # We can safely ignore if "map" is not contained in 'containers'!
        pass
    # Create header/source-files.
    create_more_container_files(headerDir, ".hpp", maxElements, containers, containersWithoutMap)
    create_more_container_files(sourceDir, ".cpp", maxElements, containers, containersWithoutMap)
286173
function resizeWordsCloud() {
         $timeout(function() {
            var element = document.getElementById('wordsCloud');
            var height = $window.innerHeight * 0.75;
            element.style.height = height + 'px';
            var width = element.getBoundingClientRect().width;
            var maxCount = originWords[0].count;
            var minCount = originWords[originWords.length - 1].count;
            var maxWordSize = width * 0.15;
            var minWordSize = maxWordSize / 5;
            var spread = maxCount - minCount;
            if (spread <= 0) spread = 1;
            var step = (maxWordSize - minWordSize) / spread;
            self.words = originWords.map(function(word) {
               return {
                  text: word.text,
                  size: Math.round(maxWordSize - ((maxCount - word.count) * step)),
                  color: self.customColor,
                  tooltipText: word.text + ' tooltip'
               };
            });
            self.width = width;
            self.height = height;
            self.padding = self.editPadding;
            self.rotate = self.editRotate;
         });
      }
1325896
def negated(input_words, include_nt=True):
    
    input_words = [str(w).lower() for w in input_words]
    neg_words = []
    neg_words.extend(NEGATE)
    for word in neg_words:
        if word in input_words:
            return True
    if include_nt:
        for word in input_words:
            if "n't" in word:
                return True
    if "least" in input_words:
        i = input_words.index("least")
        if i > 0 and input_words[i - 1] != "at":
            return True
    return False
330621
def generate_data_with_shared_vocab(self, data_dir, tmp_dir, task_id=-1):
    """"""
    global_vocab_filename = os.path.join(data_dir, self.vocab_filename)
    if not tf.gfile.Exists(global_vocab_filename):
      raise ValueError(
          'Global vocabulary file: %s does not exist, '
          'please create one using build_vocab.py' % global_vocab_filename)
    # Before generating data, we copy the global vocabulary file to the children
    # locations. Although this is not the most disk efficient strategy, it
    # imposes the fewest changes to the text-to-text API.
    for p in self.problems:
      local_vocab_filename = os.path.join(data_dir, p.vocab_filename)
      if not tf.gfile.Exists(local_vocab_filename):
        tf.gfile.Copy(global_vocab_filename, local_vocab_filename)
      p.generate_data(data_dir, tmp_dir, task_id)
823307
def generate_words(numberofwords, wordlist, secure=None):
    """"""
    if not secure:
        chooser = random.choice
    else:
        chooser = random.SystemRandom().choice
    return [chooser(wordlist) for _ in range(numberofwords)]
1239622
def load_words(wordlist=None):
    
    global words
    if not wordlist:
        # no wordlist was provided, load the wordlist from the local store
        filename = get_data('wordlist.txt')
        f = open(filename)
        wordlist = f.readlines()
        wordlist = [w.strip() for w in wordlist if w]
    words = wordlist
867068
def text_cloud(self,text,max_text_size=72,min_text_size=12,expand_width=50,expand_height=50,max_count=100000):
        ''''''
        worddict = assign_fonts(tuplecount(text),max_text_size,min_text_size,self.exclude_words)
        sorted_worddict = list(reversed(sorted(worddict.keys(), key=lambda x: worddict[x])))
        for word in sorted_worddict:
            self.render_word(word,worddict[word],(randint(0,255),randint(0,255),randint(0,255)))
            if self.width < self.word_size[0]:
                #If the word is bigger than the surface, expand the surface.
                self.expand(self.word_size[0]-self.width,0)
            elif self.height < self.word_size[1]:
                self.expand(0,self.word_size[1]-self.height)
            position = [randint(0,self.width-self.word_size[0]),randint(0,self.height-self.word_size[1])]
            loopcount = 0
            while self.collides(position,self.word_size):
                if loopcount > max_count:
                #If it can't find a position for the word, expand the cloud.
                    self.expand(expand_width,expand_height)
                    loopcount = 0
                position = [randint(0,self.width-self.word_size[0]),randint(0,self.height-self.word_size[1])]
                loopcount += 1
            self.plot_word(position)
231644
def add_input_file(self, filename):
    
    if filename not in self.__input_files:
      self.__input_files.append(filename)
977811
def create(self, *args, **kwargs):
        
        try:
            return super(CloudBlockStorageManager, self).create(*args,
                    **kwargs)
        except exc.BadRequest as e:
            msg = e.message
            if "Clones currently must be >= original volume size" in msg:
                raise exc.VolumeCloneTooSmall(msg)
            else:
                raise
134905
public SampleSetEQOracle<I, D> add(Word<I> input, D expectedOutput) {
        testQueries.add(new DefaultQuery<>(input, expectedOutput));
        return this;
    }
96214
async def CreatePool(self, attrs, name, provider):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Storage',
                   request='CreatePool',
                   version=3,
                   params=_params)
        _params['attrs'] = attrs
        _params['name'] = name
        _params['provider'] = provider
        reply = await self.rpc(msg)
        return reply
538878
def visualize_cloud_of_words(dictionary, image_path=None):
        
        from PIL import Image

        if image_path is not None:
            mask = np.array(Image.open(image_path))
            wc = WordCloud(mask=mask, background_color='white', width=1600, height=1200, prefer_horizontal=0.8)
            wc = wc.generate_from_frequencies(dictionary)
        else:
            # Generate a word cloud image
            wc = WordCloud(background_color='white', width=1600, height=1200, prefer_horizontal=0.8)
            wc = wc.generate_from_frequencies(dictionary)

        # Display the generated image:
        # the matplotlib way:
        import matplotlib.pyplot as plt
        plt.rcParams['figure.figsize'] = (15, 15)
        plt.imshow(wc, interpolation='bilinear')
        plt.axis("off")
        plt.show()