示例#1
0
def getTermId(term):
    query = """SELECT id FROM tb_conceito WHERE termo='""" + str(
        term) + """'"""
    termId = aux_actions_db.consulta_BD(query)
    if len(termId) < 1:
        termId = addConcept(term, query)
    return termId
示例#2
0
def conceitoDocs(conceitoId):
    keys = ["conceitoId", "docId", "nome", "contexto", "arquivo"]
    response = []
    query = "SELECT cd.id_conceito, d.id, d.nome, d.contexto, d.arquivo FROM tb_documento d, tb_conceito_documento cd WHERE (cd.id_documento=d.id AND cd.id_conceito=\'"+str(conceitoId)+"\')"
    results = aux_actions_db.consulta_BD(query)
    for value in results:
        response.append(dictionary(keys, value))
    return response
示例#3
0
def description(conceitoId):
    keys = ["conceitoId", "termo", "description"]
    response = []
    query = "SELECT id, termo, descricao FROM tb_conceito WHERE id=\'"+str(conceitoId)+"\'"
    results = aux_actions_db.consulta_BD(query)
    for value in results:
        response.append(dictionary(keys, value))
    return response
示例#4
0
def contextos(termo):
    keys = ["conceitoId", "termo", "contexto"]
    response = []
    query = "SELECT id, termo, contexto FROM tb_conceito WHERE termo=\'"+str(termo)+"\'"
    results = aux_actions_db.consulta_BD(query)
    for value in results:
        response.append(dictionary(keys, value))
    return response
示例#5
0
def isInDB(term, desc, ctxt):
    query = """SELECT id FROM tb_conceito WHERE termo='""" + str(
        term) + """' AND descricao='""" + str(
            desc) + """' AND contexto='""" + str(ctxt) + """'"""
    conceptId = aux_actions_db.consulta_BD(query)
    if len(conceptId) < 1:
        return False
    else:
        return True
示例#6
0
def documents(docId):
    keys = ["docId", "nome", "contexto", "arquivo"]
    query = ""
    response = []
    if docId == None:
        query = "SELECT id, nome, contexto, arquivo FROM tb_documento"
    else:
        query = "SELECT id, nome, contexto, arquivo FROM tb_documento WHERE id=\'"+str(docId)+"\'"
    results = aux_actions_db.consulta_BD(query)
    for value in results:
        response.append(dictionary(keys, value))
    return response
示例#7
0
def conceitosRel(conceitoId):
    keys = ["idPrincipal", "relacao", "idSecundario"]
    query = ""
    response = []
    if conceitoId == None:
        query = "SELECT id_conceito_principal, relacao, id_conceito_secundario FROM tb_relacao_semantica"
    else:
        query = "SELECT id_conceito_principal, relacao, id_conceito_secundario FROM tb_relacao_semantica WHERE id_conceito_principal=\'"+str(conceitoId)+"\'"
    results = aux_actions_db.consulta_BD(query)
    for value in results:
        response.append(dictionary(keys, value))
    return response
示例#8
0
def conceitosInfo(conceitoId):
    keys = ["conceitoId", "termo", "descricao", "contexto"]
    query = ""
    response = []
    if conceitoId == None:
        query = "SELECT id, termo, descricao, contexto FROM tb_conceito"
    else:
        query = "SELECT id, termo, descricao, contexto FROM tb_conceito WHERE id=\'"+str(conceitoId)+"\'"
    results = aux_actions_db.consulta_BD(query)
    for value in results:
        response.append(dictionary(keys, value))
    return response
示例#9
0
def getDocumentId(document):
    query = """SELECT id FROM tb_documento WHERE nome='""" + str(
        document) + """';"""
    termId = aux_actions_db.consulta_BD(query)
    return termId
示例#10
0
def addConcept(term, query):
    query_add = """INSERT INTO tb_conceito (termo,contexto) VALUES ('""" + term + """','thing');"""
    aux_actions_db.update_BD(query_add)
    termId = aux_actions_db.consulta_BD(query)
    insertConceptDoc(termId[0][0])
    return termId
示例#11
0
	def get_users(self):
		query = 'SELECT * FROM tb_user'
		rows = aux_actions_db.consulta_BD(query)
		return rows