def demonstrate_association(): print 'Demonstrating Association API' a = Association(filter='/c/en/dog', limit=1) data = a.get_similar_concepts('cat') r = Result(data) r.print_raw_result() print a = Association() data = a.get_similar_concepts_by_term_list(['toast', 'cereal', 'juice', 'egg']) r = Result(data) r.print_raw_result() print r.parse_all_edges() print
def demonstrate_association(): print 'Demonstrating Association API' a = Association(filter='/c/en/dog', limit=1) data = a.get_similar_concepts('cat') r = Result(data) r.print_raw_result() print a = Association() data = a.get_similar_concepts_by_term_list( ['toast', 'cereal', 'juice', 'egg']) r = Result(data) r.print_raw_result() print r.parse_all_edges() print
from conceptnet5_client.web.api import Search from conceptnet5_client.web.api import Association from conceptnet5_client.utils.result import Result # get how similar cats and dogs a = Association(filter='/c/en/dog', limit=1) data = a.get_similar_concepts('cat') r = Result(data) # print results in key = value format r.print_raw_result() a = Association() data = a.get_similar_concepts_by_term_list(['toast', 'cereal', 'juice', 'egg']) r = Result(data) # print results in key = value format r.print_raw_result()
# Perform NLP Preprocessing ques = prenlp.preprocess(q.question) ans_a = prenlp.preprocess(q.a) ans_b = prenlp.preprocess(q.b) ans_c = prenlp.preprocess(q.c) ans_d = prenlp.preprocess(q.d) print "Question: " + str(q.question) print "A: " + str(q.a) print "B: " + str(q.b) print "C: " + str(q.c) print "D: " + str(q.d) # Generate Semantic Graph from Question a = Association(filter="/c/en", limit=30) semnet = a.get_similar_concepts_by_term_list(ques) r = Result(semnet) # Parse Similarity similar = r.get_similar() if len(similar) > 0: # Splice Leading API Directory for word in similar: word[0] = word[0][6:] print "\n" print similar print "\n"
ques = prenlp.preprocess(q.question) ans_a = prenlp.preprocess(q.a) ans_b = prenlp.preprocess(q.b) ans_c = prenlp.preprocess(q.c) ans_d = prenlp.preprocess(q.d) print "[Question]: " + str(ques) + "\n" print "[Answer Choices]" print "A: " + str(ans_a) print "B: " + str(ans_b) print "C: " + str(ans_c) print "D: " + str(ans_d) print print "[Correct Answer]: " + str(q.ans) + "\n" # Perform Semantic Association Search on Question a = Association() data = a.get_similar_concepts_by_term_list(ques) r = Result(data) # Obtain Associtative Edges r.parse_all_edges() print # Perform an Exhaustive Entity Frequency Search # Check to see which one contains the most amount of relevant entities. #print "[Predicted Answer]: " #print "[Correct Answer]: " + str(q.ans) + "\n"