Example #1
0
sys.path.append("..")
import insummer
import profile

from insummer.knowledge_base.entity_lookup import ConceptnetEntityLookup
from insummer.knowledge_base import concept_tool
from insummer.query_expansion.entity_expansioner import OnlySynExpansioner, SynRelateExpansioner
from insummer.common_type import Question
from insummer.query_expansion.entity_finder import example_entity_finder, NgramEntityFinder

import data

questions = data.get_data()

cn = concept_tool()
finder = NgramEntityFinder

import networkx as nx
import itertools
from operator import itemgetter
import matplotlib.pyplot as plt

#title = "How do Motorcycles pollute?"
#title = "what's wrong with my bike?"


def get_weight1(ent1, ent2):
    weight = cn.entity_strength(ent1, ent2)
    if ent1 == ent2:
        return 1
Example #2
0
import pickle

from abc import ABCMeta, abstractmethod

#others
import csv
from optparse import OptionParser

conf = config("../../conf/cn_data.conf")

data_pos = conf["csv_pos"]

part = [i for i in range(0, 8)]

cn_tool = concept_tool()
rel_tool = relation_tool()


#得到第i份part的名字
def get_ipart_name(i):
    return "%spart_0%s.csv" % (data_pos, part[i])


def get_ipart_handler(i):
    assert int(i) in part

    fname = get_ipart_name(int(i))
    fi = open(fname)
    reader = csv.reader(fi, delimiter='\t')
    return reader
Example #3
0
import insummer
from insummer.read_conf import config
from insummer.knowledge_base import concept_tool
from insummer.knowledge_base.relation import relation_tool


#others
import csv

conf = config("../../conf/cn_data.conf")

data_pos = conf["csv_pos"]

part = [i for i in range(0,8)]

cp_tool = concept_tool()
rel_tool = relation_tool()

#得到第i份part的名字
def get_ipart_name(i):
    return "%spart_0%s.csv"%(data_pos,part[i])

def get_ipart_handler(i):
    assert int(i) in part
    
    fname = get_ipart_name(int(i))
    fi = open(fname)
    reader = csv.reader(fi,delimiter='\t')
    return reader

#三元组的限制
Example #4
0
 def setUp(self):
     self.cn = concept_tool()
     self.re = relation_tool()
     self.finder = InsunnetFinder()
     self.cel = ConceptnetEntityLookup()
     self.iel = InsunnetEntityLookup()
Example #5
0
import pickle

from abc import ABCMeta, abstractmethod

#others
import csv
from optparse import OptionParser

conf = config("../../conf/cn_data.conf")

data_pos = conf["csv_pos"]

part = [i for i in range(0,8)]

cn_tool = concept_tool()
rel_tool = relation_tool()

#得到第i份part的名字
def get_ipart_name(i):
    return "%spart_0%s.csv"%(data_pos,part[i])

def get_ipart_handler(i):
    assert int(i) in part
    
    fname = get_ipart_name(int(i))
    fi = open(fname)
    reader = csv.reader(fi,delimiter='\t')
    return reader

Example #6
0
 def setUp(self):
     self.cn = concept_tool()
     self.re = relation_tool()
     self.finder = InsunnetFinder()
     self.cel = ConceptnetEntityLookup()
     self.iel = InsunnetEntityLookup()
Example #7
0
import sys
sys.path.append("..")
import insummer
import profile


from insummer.knowledge_base.entity_lookup import ConceptnetEntityLookup
from insummer.knowledge_base import concept_tool
from insummer.query_expansion.entity_expansioner import OnlySynExpansioner,SynRelateExpansioner
from insummer.common_type import Question
from insummer.query_expansion.entity_finder import example_entity_finder,NgramEntityFinder

import data
questions = data.get_data()

cn = concept_tool()
finder = NgramEntityFinder

#title = "How do Motorcycles pollute?"
#title = "what's wrong with my bike?"


if __name__ == '__main__':

    #for i in range(len(questions)):
    for i in range(1):
        print(i)
        q = questions[i]
        #exp = OnlySynExpansioner(q,finder,max_level=2,display=True)
        exp = SynRelateExpansioner(q,finder,max_level=1,display=True)
        exp.run()