# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# 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