1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

keywords.top()

Syntax

top(string, n=10, nouns=False)

Description

Returns a list of 2-tuples, for example [(5,"typography"), (2,"workshop")], representing the most important words in the string of text, and their count. The top() command returns the top n words.

Optionally, you can set the nouns parameter to True to filter for nouns using WordNet. Naturally, the WordNet package needs to be accessible.

Example

Filters the keywords from Lucas Nijs' text, Ideas from the Heart.

import keywords
string = open("ideasfromtheheart.txt").read()
top = keywords.top(string, nouns=True)
for count, word in top:
  print count, word
>>>8 typography
>>>4 project
>>>4 communication
>>>3 workshop
>>>3 teacher
>>>3 media
>>>3 communicating
>>>3 design
>>>2 whole
>>>2 week