def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.QExpInName = conf.GetConf('qexp')
     self.lClusterLmInName = conf.GetConf('clusterlm')
     if type(self.lClusterLmInName) != list:
         self.lClusterLmInName = [self.lClusterLmInName]
     self.OutName = conf.GetConf('out')
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.CtfCenter.Load(conf.GetConf('termctf'))
     self.Word2VecFile = conf.GetConf('word2vec')
     self.CateDenseCenter.load(conf.GetConf('cateattdense'))
     self.FbObjCacheCenter.SetConf(ConfIn)
     print "inited"
    def SetConf(self,ConfIn):
        conf = cxConf(ConfIn)
        self.WorkDir = conf.GetConf('objcachedir') + '/'
#         print "set obj cachedir to [%s]" %(self.WorkDir)
#         self.WriteCache = bool(int(conf.GetConf('writecache',self.WriteCache)))
#         self.CreateHash()
        return True
Beispiel #4
0
 def SetConf(self, ConfIn):
     conf = cxConf(ConfIn)
     self.QExpInName = conf.GetConf('qexp')
     self.lClusterLmInName = conf.GetConf('clusterlm')
     if type(self.lClusterLmInName) != list:
         self.lClusterLmInName = [self.lClusterLmInName]
     self.OutName = conf.GetConf('out')
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.CashDir = conf.GetConf('cashdir')
     self.QueryIn = conf.GetConf('in')
     self.FaccDir = conf.GetConf('faccdir')
     self.OutDir = conf.GetConf('outdir')
     self.SERPDepth = int(conf.GetConf('serpdepth',self.SERPDepth))
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
 #    self.WOrig = float(conf.LoadConf("worig"))
     self.DirMu = float(conf.GetConf('dirmu',self.DirMu))
     self.NumOfExpTerm = int(conf.GetConf("numofexpterm",self.NumOfExpTerm))
     self.PrfDocNum = int(conf.GetConf('prfdocnum',self.PrfDocNum))
     self.CtfCenter.Load(conf.GetConf("ctfpath"))
     return True
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.FilterCotype = bool(conf.GetConf('cotypefilter',self.CotypeFilter))
     self.filterdomain = conf.GetConf('filterdomain')
     if type(self.filterdomain) != list:
         self.filterdomain = [self.filterdomain]
     self.InGraphDir = conf.GetConf('ingraphdir')
     self.OutGraphDir = conf.GetConf('outgraphdir')
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.NumOfObjUsed = int(conf.GetConf('numofobj',self.NumOfObjUsed))
     self.CtfCenter.Load(conf.GetConf('ctfpath'))        
     self.ObjCenter.SetConf(ConfIn)
     self.NumOfExpTerm = int(conf.GetConf('numofexpterm',self.NumOfExpTerm))
     self.QObjRankInName = conf.GetConf('queryobjrank')
     return
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.InName = conf.GetConf('in')
     self.OutName = conf.GetConf('out')
     self.k = int(conf.GetConf('k',self.k))
     self.MidDir = conf.GetConf('middir')
     self.Model = cxKMeansC()
     self.Model.SetK(self.k)
     self.Model.SetWorkDir(self.MidDir)
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.lEdgeFeature = conf.GetConf('edgefeature', self.lEdgeFeature)
     self.KeepPRFFeature = bool(int(conf.GetConf('keepprf',1)))
     self.KeepPRALvl1Feature = bool(int(conf.GetConf('keeplvl1',1)))
     self.KeepPRALvl2Feature = bool(int(conf.GetConf('keeplvl2',0)))
     self.OutName = conf.GetConf('out')
     self.TermIn = conf.GetConf('in')
     self.EdgeTypeGrouping = conf.GetConf('edgetypegrouping',self.EdgeTypeGrouping)
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.FaccDocDir= conf.GetConf('faccdocdir')
     self.InName = conf.GetConf('in')
     self.OutName = conf.GetConf('out')
     CtfInName = conf.GetConf('objctf')
     if "" != CtfInName:
         self.FaccCtf.Load(CtfInName)
         print "ctf load from [%s]" %(CtfInName)
 def SetConf(self,ConfIn):
     self.LinearReranker.SetConf(ConfIn)
     self.Evaluator.SetConf(ConfIn)
     
     conf = cxConf(ConfIn)
     self.IndriResDir = conf.GetConf('cashdir')
     self.NewTermW = float(conf.GetConf('newtermweight',self.NewTermW))
     self.EvaDepth = self.Evaluator.Depth 
     self.UseBinaryScore = bool(int(conf.GetConf('usebinaryscore',0)))
def ObjVecMakerUnitRun(ConfIn):
    conf = cxConf(ConfIn)
    InName = conf.GetConf('in')
    OutName = conf.GetConf('out')
    
    Maker = ObjVecMakerC(ConfIn)
    Maker.ProcessQObjFile(InName, OutName)
    
    return True
Beispiel #14
0
 def SetConf(self, ConfIn):
     conf = cxConf(ConfIn)
     self.InName = conf.GetConf('in')
     self.OutName = conf.GetConf('out')
     self.k = int(conf.GetConf('k', self.k))
     self.MidDir = conf.GetConf('middir')
     self.Model = cxKMeansC()
     self.Model.SetK(self.k)
     self.Model.SetWorkDir(self.MidDir)
Beispiel #15
0
 def SetConf(self, ConfIn):
     conf = cxConf(ConfIn)
     self.NumOfObjUsed = int(conf.GetConf('numofobj', self.NumOfObjUsed))
     self.CtfCenter.Load(conf.GetConf('ctfpath'))
     self.ObjCenter.SetConf(ConfIn)
     self.NumOfExpTerm = int(conf.GetConf('numofexpterm',
                                          self.NumOfExpTerm))
     self.QObjRankInName = conf.GetConf('queryobjrank')
     return
def BfsQueryFreebaseUnitRun(ConfIn):
    conf = cxConf(ConfIn)
    InName = conf.GetConf('in')
    BFSer = BfsQueryFreebaseC(ConfIn)
    
    for line in open(InName):
        qid,query = line.strip().split('\t')
        BFSer.BFS(qid,query)
    BFSer.CleanUp()
    return True
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.OutDir = conf.GetConf('out')
     if not os.path.isdir(self.OutDir):
         os.makedirs(self.OutDir)
         
     self.EdgeObjIn = conf.GetConf('in')
     self.FbDumpIn = conf.GetConf('fbdumpin')
     self.FaccDir = conf.GetConf('faccdir')
     self.MaxOccurPerEdge = int(conf.GetConf('maxoccurperedge',self.MaxOccurPerEdge))
def QuerySubgraphConstructorUnitRun(ConfIn):
    conf = cxConf(ConfIn)
    InName = conf.GetConf('in')
    BFSer = QuerySubgraphConstructorC(ConfIn)
    
    for line in open(InName):
        qid,query = line.strip().split('\t')
        BFSer.BFS(qid,query)
    BFSer.CleanUp()
    return True
def QExpParaEvaResCollectorUnitTest(ConfIn):
    QExpParaEvaResCollectorC.ShowConf()
    print "out"
    conf = cxConf(ConfIn)
    OutName = conf.GetConf('out')
    Collector = QExpParaEvaResCollectorC(ConfIn)
    
    hDict = Collector.Process()
    out = open(OutName,'w')
    json.dump(hDict,out)
    out.close()
    
    print "done"
    return True
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.WorkDir = conf.GetConf('workdir')
     self.ObjectCashDir = self.WorkDir + "/obj"
     if not os.path.isdir(self.ObjectCashDir):
         os.makedirs(self.ObjectCashDir)
     
     self.BFSLvl = int(conf.GetConf('bfslvl',self.BFSLvl))
     self.MaxSearchRes = int(conf.GetConf('maxsearchres',self.MaxSearchRes))
     self.MaxCoTypeExp = int(conf.GetConf('maxcotypeexp',self.MaxCoTypeExp))
     self.MaxNeighborExp = int(conf.GetConf('maxneighborexp',self.MaxNeighborExp))
     self.DumpCache = bool(int(conf.GetConf('dumpcache',1)))
     self.load()
     return True
 def SetConf(self,ConfIn):
    
     
     self.CandidateTermGetter.SetConf(ConfIn)
     self.TermLabelGetter.SetConf(ConfIn)
     self.FeatureExtractor.SetConf(ConfIn)
     conf  = cxConf(ConfIn)
     self.OutFormat = conf.GetConf('outformat')
     self.TotalDocToRead = conf.GetConf('totalserpnum')
     self.CashDir = conf.GetConf('cashdir')
     
     self.GenerateTerm = bool(int(conf.GetConf('generateterm',1)))
     self.LabelTerm = bool(int(conf.GetConf('labelterm',1)))
     self.ExtractPRFFeature = bool(int(conf.GetConf('extractprffeature',1)))
     return True
def SingleTermPerformanceUnitTest(ConfIn):
    conf = cxConf(ConfIn)
    InName = conf.GetConf('in')
    OutName = conf.GetConf('out')
    SingleTermPerformance = SingleTermPerformanceC(ConfIn)
    CurrentQ = ""
    CurrentQid = ""
    lTerm = []
    out = open(OutName,'w')
    
    for line in open(InName):
        line = line.strip()
        vCol = line.split('\t')
        if len(vCol) < 3:
            continue
        qid = vCol[0]
        query = vCol[1]
        term = vCol[2]
        if CurrentQ == "":
            CurrentQ = query
            CurrentQid = qid
        if CurrentQ != query:
            print "working query [%s]" %(CurrentQ)
            lTermScore = SingleTermPerformance.EvaluatePerQ(CurrentQid, CurrentQ, lTerm)
            for i in range(len(lTerm)):
                print >>out, qid + '\t' + query + '\t' + lTerm[i] + '\t%f' %(lTermScore[i])
            CurrentQ = query
            CurrentQid = qid
            lTerm = []
        lTerm.append(term)
    print "working query [%s]" %(CurrentQ)
    lTermScore = SingleTermPerformance.EvaluatePerQ(CurrentQid, CurrentQ, lTerm)
    for i in range(len(lTerm)):
        print >>out, qid + '\t' + query + '\t' + lTerm[i] + '\t%f' %(lTermScore[i])        
    out.close()        
    return True
    global MinGroup
    global MaxGroup
    llSubGroup = []
    for i in range(MinGroup,min(MaxGroup,len(lGroup))+1):
        lSubGroup = [list(item) for item in itertools.combinations(lGroup,i)]
        llSubGroup.extend(lSubGroup)
    return llSubGroup




if 2 != (len(sys.argv)):
    print "conf:\nin\noutdir\ngroup prf#pralvl0#pralvl1#word2vec#hyper\nmingroup\nmaxgroup"
    sys.exit()
    
conf = cxConf(sys.argv[1])
InName = conf.GetConf('in')
OutDir = conf.GetConf('outdir')
if not os.path.isdir(OutDir):
    os.makedirs(OutDir)
    
lGroup = conf.GetConf('group')
MinGroup = int(conf.GetConf('mingroup'))
MaxGroup = int(conf.GetConf('maxgroup'))


llSubGroup = EnumrateGroup(lGroup)

llExpTerm = ReadQExpTerms(InName)

for lSubGroup  in llSubGroup:
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.FbDumpIn = conf.GetConf('dumpin')
     self.OutName = conf.GetConf('out')
Beispiel #25
0
 def SetConf(self, ConfIn):
     conf = cxConf(ConfIn)
     self.FbDumpIn = conf.GetConf('dumpin')
     self.OutName = conf.GetConf('out')
 def SetConf(self,ConfIn):
     super(QExpParaEvaResCollectorC,self).SetConf(ConfIn)
     conf = cxConf(ConfIn)
     self.MainEvaMethod = conf.GetConf('mainevamethod')
     return True
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.InName = conf.GetConf('in')
     self.OutName = conf.GetConf('out')
     
     self.Model.SetWorkDir(conf.GetConf('middir'))
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.InQuery = conf.GetConf('in')
     self.OutName = conf.GetConf('out')
Beispiel #29
0
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.FaccDir = conf.GetConf('faccdir')
     self.InTargetObj = conf.GetConf('in')
     self.OutName = conf.GetConf('out')
     self.InType = conf.GetConf('fakba')
Beispiel #30
0
    def SetConf(self, ConfIn):
        conf = cxConf(ConfIn)
        self.InName = conf.GetConf('in')
        self.OutName = conf.GetConf('out')

        self.Model.SetWorkDir(conf.GetConf('middir'))
 def SetConf(self,ConfIn):
     super(QuerySubgraphTargetTermFilterC,self).SetConf(ConfIn)
     conf = cxConf(ConfIn)
     self.GraphDumpDir = conf.GetConf('graphdumpdir')
     self.OutDir = conf.GetConf('outdir')
    hResExp = {}
    if not Intersect:
        hResExp = deepcopy(hExpTerm)
    else:
        for item in hIntersect:
            hResExp[item] = deepcopy(hExpTerm[item])
    return hResExp


if 2 != len(sys.argv):
    print "conf:"
    print "target\nmergefile\nintersect 1\nout"
    sys.exit()

conf = cxConf(sys.argv[1])
TargetIn = conf.GetConf('target')
lInName = conf.GetConf('mergefile')
OutName = conf.GetConf('out')
if type(lInName) == str:
    lInName = [lInName]
Intersect = bool(int(conf.GetConf('intersect', 1)))

hExpTerm = LoadAndMergeOneExpTerm(TargetIn)
hResExp = MergeFilesToADict(hExpTerm, lInName, Intersect)

lExpTerm = [ExpTerm for key, ExpTerm in hResExp.items()]
lExpTerm.sort(key=attrgetter('qid'))

out = open(OutName, 'w')
for ExpTerm in lExpTerm:
 def SetConf(self,ConfIn):
     conf = cxConf(ConfIn)
     self.k = int(conf.GetConf('k', self.k))
     self.InName = conf.GetConf('in')
     self.OutName = conf.GetConf('out')