Esempio n. 1
0
from django.conf.urls.defaults import *
from wordnik import Wordnik

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

w = Wordnik(api_key="1d3baf57f57254b5c430200e729037e9dea9d87493f3a16b4")
urlpatterns = patterns(
    '',
    (r'^(?P<mode>.*)/$', 'play.views.index', {
        "w": w
    }),
    #(r'^mix$', 'play.mix.index', { "w": w } ),
    # Example:
    # (r'^wordrainbow/', include('wordrainbow.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # (r'^admin/', include(admin.site.urls)),
)
Esempio n. 2
0
#!/usr/bin/python
from wordnik import Wordnik

word = Wordnik(api_key='1cc793b4b4ce10c19417b080bb20ecf919bdb5e01fb1eddfc')

x = ' '

while x:
    x = raw_input('\n\nplease enter a word: ')
    define = word.word_get_definitions(x)
    n = 0
    raw = 'y'
    try:
        print '\n', define[n]['text'].upper()
    except IndexError:
        print '\t\tNo Definition'.upper()
        break
    while raw[0] == 'y':
        x = raw_input('\nWould you like the next definition? (y or n): ').lower()
        if x and x[0] == 'y':
            try:
                n += 1
                print '\n', define[n]['text'].upper()
            except IndexError:
                print '\t\tno more definitions'.upper()
                continue
        else:
            break
print '\n\t\tGoodbye'

Esempio n. 3
0
#this can be done from the commandline by typing: easy_install Wordnik
try:
    from wordnik import Wordnik
except ImportError:
    raise NecessaryModuleNotFound(
        "Wordnik library not found. Please install wordnik library! e.g. sudo easy_install wordnik"
    )

#You need a wordnik api key, you can get yours at http://developer.wordnik.com/ (first you sign up for a username in the upp$
########################################################

wordnik_api_key = APIKeyForAPI("wordnik")

#########################################################

w = Wordnik(api_key=wordnik_api_key)


class define(Plugin):
    @register("en-US", "define ([\w ]+)")
    def defineword(self, speech, language, regMatched):
        Question = regMatched.group(1)
        output = w.word_get_definitions(Question, limit=1)
        if len(output) == 1:
            answer = dict(output[0])
            if u'text' in answer:
                worddef = answer[u'text']
                if worddef:
                    self.say(
                        worddef, "The definition of {0} is: {1}".format(
                            Question, worddef))
Esempio n. 4
0
#!/usr/bin/env python

import httplib, json, random, sys

from wordnik import Wordnik

w = Wordnik(api_key="d92d8109432f0ead8000707303d0c6849e23be119a18df853",
            username="******",
            password="******")


def add_word(word):
    token = w.token
    key = w._api_key
    headers = {
        "api_key": key,
        "auth_token": token,
        'Content-Type': 'application/json'
    }

    conn = httplib.HTTPConnection("api.wordnik.com")

    uri = "/v4/wordList.json/wordrainbow/words?username=wordrainbow"
    body = json.dumps([{
        "word": word,
    }])

    print body
    conn.request("POST", uri, body, headers)
    r = conn.getresponse()
    return r.status, r.reason
Esempio n. 5
0
web.config.debug = False

urls = (
    '/mix',         'Mix',
    '/identify',    'Identify',
    '/visualize',   'Visualize',
    '/play',        'Play',
    '/',            'Index',
)

alnum = map(chr, range(97, 123)) + [str(n) for n in range(0,10)]
KEY="d92d8109432f0ead8000707303d0c6849e23be119a18df853"
# w = Wordnik(api_key="1d3baf57f57254b5c430200e729037e9dea9d87493f3a16b4",username="******",password="******")
## privileged key!
wnk = Wordnik(api_key=KEY,username="******",password="******")
all_colors = uberList([ w['word'] for w in json.loads(wnk.word_list_get_words("wordrainbow")) ])
hexen = create_hexen()

class Mix(object):
    def GET(self):
        web.header("Access-Control-Allow-Origin", "*")
        
        if session.get("mixing", False):
            return self.mix()
        else:
            return self.initialize_session()
    
    
    def mix(self):
        query_params = web.input(name=None,hex=None,callback="callback")