def getinterpretations(request):
    mongohost = request.registry.settings['MONGOHOST']
    log.info('Getting all TF-Idf results')
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='KnowledgeModelTfIdf',
            collection='tfidf')
    return (ma.getRecords())
def gettfidfs(request):
    mongohost = request.registry.settings['MONGOHOST']
    domain = request.matchdict.get('domain').replace(' ', '_')
    log.info('Getting all TF-Idf results for domain {}'.format(domain))
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='KnowledgeModelTfIdf',
            collection=domain)
    return (ma.getRecords())
def getquestionterms(request):
    mongohost = request.registry.settings['MONGOHOST']
    log.info('Getting pos terms')
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='vizwiz',
            collection='Dictionary')
    record = ma.getRecords()
    return record
def getspellcheckcorpus(request):
    mongohost = request.registry.settings['MONGOHOST']
    log.info('Getting spell check corpus')
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='vizwiz',
            collection='Spelling')
    record = ma.getRecords()
    return record
def getinterpretations(request):
    mongohost = request.registry.settings['MONGOHOST']
    log.info('Getting all Visualizations for ID')
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='vizwiz',
            collection='Interpretations')
    record = ma.getRecords()
    return record
def getdatasets(request):
    mongohost = request.registry.settings['MONGOHOST']
    log.info('Getting all DataSets for ID')
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='vizwiz',
            collection='DataSets')
    record = ma.getRecords()
    return record
def getschema(request):
    mongohost = request.registry.settings['MONGOHOST']
    sId = request.matchdict.get('sid')
    log.info('Getting Schema for ID : ' + sId)
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='vizwiz',
            collection='Schemas')
    record = ma.getRecord({"sId": sId})
    return record
def getcorpus(request):
    mongohost = request.registry.settings['MONGOHOST']
    corpus = request.matchdict.get('corpus')
    log.info('Getting Corpus : getcorpus:' + corpus)
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='KnowledgeModelCorpora',
            collection='corpora')
    record = ma.getRecord({"corpus": corpus})
    return record
def getvisualization(request):
    mongohost = request.registry.settings['MONGOHOST']
    visualizationame = request.matchdict.get('visualizationame')
    log.info('Getting Visualisation for name : ' + visualizationame +
             " mongo host : " + mongohost)
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='vizwiz',
            collection='Visualizations')
    record = ma.getRecord({"name": visualizationame})
    return record
def gettfidf_for_domain(request):
    mongohost = request.registry.settings['MONGOHOST']
    domain = request.matchdict.get('domain')
    corpus = request.matchdict.get('corpus')
    log.info('Getting TF-IDF for Domain : domain:' + domain + " corpus :" +
             corpus)
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='KnowledgeModelTfIdf',
            collection='tfidf')
    record = ma.getRecord({"domain": domain, "corpus": corpus})
    return record
def gettaxonomy_for_domain(request):
    mongohost = request.registry.settings['MONGOHOST']
    domain = request.matchdict.get('domain')
    log.info('Getting Taxonomy for Domain : domain:' + domain)
    ma = MA(host=mongohost,
            port=27017,
            logger=logger,
            db='KnowledgeModelTaxonomy',
            collection=domain.replace(' ', '_'))
    record = ma.getRecord({"domain": domain})
    if record is None:
        raise exc.HTTPBadRequest(
            explanation="The domain {} does not have a taxonomy in the database."
            .format(domain))

    return record