Example #1
0
def get_pos(word):
    wordAPI = WordAPI(client)
    input = wordnik.model.WordDefinitionsInput.WordDefinitionsInput()
    input.word = word
    input.limit = 2
    input.useCanonical = True
    input.sourceDictionaries = 'webster'
    definitions = wordAPI.getDefinitions(input)
    pos_list = []
    if definitions:
        for definition in definitions:
            pos_list.append(definition.partOfSpeech)
    return pos_list
Example #2
0
def get_def(word):
    wordAPI = WordAPI(client)
    input = wordnik.model.WordDefinitionsInput.WordDefinitionsInput()
    input.word = word
    input.limit = 2
    input.useCanonical = True
    input.sourceDictionaries = 'webster'
    definitions = wordAPI.getDefinitions(input)
    def_list = []
    if definitions:
        for definition in definitions:
            def_list.append(definition.text)
    return def_list
Example #3
0
import os
import pdb

from flask import Flask, render_template, request, flash, session, redirect, url_for
from wordnik.api.APIClient import APIClient
from wordnik.api.WordAPI import WordAPI
import wordnik.model

from db import *
from wordnik_api_key import *

client = APIClient(api_key, 'http://api.wordnik.com/v4')
wordAPI = WordAPI(client)
lookup = wordnik.model.WordDefinitionsInput.WordDefinitionsInput()

DEBUG = True
SECRET_KEY = 'development key'
USERNAME = '******'
PASSWORD = '******'

app = Flask(__name__)
app.config.from_object(__name__)
WC = WordCountTable('linguist', 'sitong', tableName='WordCount')
Users = UserTable('linguist', 'sitong', tableName='Users')

@app.route('/')
def main():
    if 'logged_in' not in session:
        session['logged_in'] = False
    if 'username' in session:
        return render_template('main.html', username=session['username'],