本文整理汇总了Python中pydblite.Base.create_index方法的典型用法代码示例。如果您正苦于以下问题:Python Base.create_index方法的具体用法?Python Base.create_index怎么用?Python Base.create_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydblite.Base
的用法示例。
在下文中一共展示了Base.create_index方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateWeights
# 需要导入模块: from pydblite import Base [as 别名]
# 或者: from pydblite.Base import create_index [as 别名]
def generateWeights(graph, weightFile, param):
pdb = Base(weightFile)
pdb.create('pair', 'node1', 'node2','FTI01','FTI02','FTI03','FTI04','FTI05','FTI06','FTI07','FTI08','FTI09')
pdb.create_index('pair')
sortedNodes = sorted(graph.nodes())
for node in sortedNodes:
others = sorted(set(n for n in sortedNodes if n > node))
for other in others:
if graph.has_edge(node, other):
informations = list(edge for n1, n2, edge in graph.edges([node, other], data=True) if ((n1 == node and n2 == other) or (n1 == other and n2 == node)) )
timesofLinks = []
for info in informations:
timesofLinks.append(int(info['time']))
total_publications = len(informations)
k = int(param.t0_) - max(timesofLinks)
FTI01 = total_publications * (0.1**k)
FTI02 = total_publications * (0.2**k)
FTI03 = total_publications * (0.3**k)
FTI04 = total_publications * (0.4**k)
FTI05 = total_publications * (0.5**k)
FTI06 = total_publications * (0.6**k)
FTI07 = total_publications * (0.7**k)
FTI08 = total_publications * (0.8**k)
FTI09 = total_publications * (0.9**k)
pdb.insert(str(node) + ';' + str(other),node,other, FTI01, FTI02, FTI03, FTI04, FTI05, FTI06, FTI07, FTI08, FTI09 )
pdb.commit()
return pdb
示例2: generateWeights
# 需要导入模块: from pydblite import Base [as 别名]
# 或者: from pydblite.Base import create_index [as 别名]
def generateWeights(graph, weightFile, param):
pdb = Base(weightFile)
pdb.create('pair', 'node1', 'node2','TS02','TS05','TS08', 'JC')
pdb.create_index('pair')
sortedNodes = sorted(graph.nodes())
for node in sortedNodes:
others = sorted(set(n for n in sortedNodes if n > node))
for other in others:
if graph.has_edge(node, other):
informations = list(edge for n1, n2, edge in graph.edges([node, other], data=True) if ((n1 == node and n2 == other) or (n1 == other and n2 == node)) )
timesofLinks = []
for info in informations:
timesofLinks.append(int(info['time']))
bagNode1 = list(eval(edge['keywords']) for n1, n2, edge in graph.edges([node], data=True) if (n1 != other and n2 != other) )
bagNode2 = list(eval(edge['keywords']) for n1, n2, edge in graph.edges([other], data=True) if (n1 != node and n2 != node) )
total_publications = len(informations)
k = int(param.t0_) - max(timesofLinks)
decayfunction02 = (1 - 0.2) ** k
decayfunction05 = (1 - 0.5) ** k
decayfunction08 = (1 - 0.8) ** k
pdb.insert(str(node) + ';' + str(other),node,other,(total_publications * decayfunction02) , (total_publications * decayfunction05) , (total_publications * decayfunction08), get_jacard_domain(bagNode1, bagNode2) )
pdb.commit()
return pdb
示例3: generate_finalResult
# 需要导入模块: from pydblite import Base [as 别名]
# 或者: from pydblite.Base import create_index [as 别名]
def generate_finalResult(order,topRank, TestGraph, FileNameResult ):
pdb = Base(FileNameResult)
pdb.create('node1', 'node2', 'value', 'sucesso','topRank')
pdb.create_index('node1', 'node2')
indice = 0
for nodeToCheck in order:
indice = indice+1
isTopRank = (indice <= topRank)
if (TestGraph.has_edge(nodeToCheck['node1'],nodeToCheck['node2'])):
pdb.insert(str(nodeToCheck['node1']), nodeToCheck['node2'],nodeToCheck['value'] , True, isTopRank )
else:
pdb.insert(str(nodeToCheck['node1']), nodeToCheck['node2'],nodeToCheck['value'] , False, isTopRank )
pdb.commit()
return pdb
示例4: calculatingWeights
# 需要导入模块: from pydblite import Base [as 别名]
# 或者: from pydblite.Base import create_index [as 别名]
def calculatingWeights(graph, nodesnotLinked, database, calculatingFile):
pdb = Base(calculatingFile)
pdb.create('node1', 'node2', 'cnWTS02','cnWTS05','cnWTS08', 'aaWTS02', 'aaWTS05', 'aaWTS08')
pdb.create_index('node1', 'node2')
element = 0
qtyofNodesToProcess = len(nodesnotLinked)
for pair in nodesnotLinked:
element = element+1
FormatingDataSets.printProgressofEvents(element, qtyofNodesToProcess, "Calculating features for nodes not liked: ")
neighbors_node1 = all_neighbors(graph, pair[0])
neighbors_node2 = all_neighbors(graph, pair[1])
len_neihbors_node1 = len(neighbors_node1)
len_neihbors_node2 = len(neighbors_node2)
CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
CNWts02Feature = 0;
CNWts05Feature = 0;
CNWts08Feature = 0;
AAWts02Feature = 0;
AAWts05Feature = 0;
AAWts08Feature = 0;
CNWJCFeature = 0;
AAWJCFeature = 0;
for cn in CommonNeigbors:
item = get_partOfWeightCalculating(graph, database, pair, cn)
CNWts02Feature = CNWts02Feature + item['cnWts02'];
CNWts05Feature = CNWts05Feature + item['cnWts05'];
CNWts08Feature = CNWts08Feature + item['cnWts08'];
AAWts02Feature = AAWts02Feature + item['aaWts02'];
AAWts05Feature = AAWts05Feature + item['aaWts05'];
AAWts08Feature = AAWts08Feature + item['aaWts08'];
#CNWJCFeature = CNWJCFeature + item['cnWJC'];
#AAWJCFeature = AAWJCFeature + item['aaWJC'];
pdb.insert(str(pair[0]), str(pair[1]), CNWts02Feature, CNWts05Feature, CNWts08Feature, AAWts02Feature, AAWts05Feature, AAWts08Feature )
pdb.commit()
return pdb;
示例5: __init__
# 需要导入模块: from pydblite import Base [as 别名]
# 或者: from pydblite.Base import create_index [as 别名]
class Rates:
""" Persistence layer for exchange rates. """
def __init__(self, filename, erase_db):
self.__db = Base(filename)
self.__db.create('currency', 'rate', mode="override" if erase_db else "open")
self.__db.create_index('currency')
def setRate(self, currency, rate):
""" Persist a currency's exchange rate. """
assert rate > 0.0
records = self.__db._currency[currency]
if len(records) > 0:
assert len(records) == 1 # We never expect several exchange rates for the same currency
self.__db.update(records[0], rate = rate)
else:
self.__db.insert(currency = currency, rate = rate)
self.__db.commit()
def getRate(self, currency):
""" Get the exchange rate with EUR for the provided currency or None if it is not found.
An exchange rate for currency CUR is Value(EUR) / Value(CUR): 1 EUR = rate(CUR) CUR <=> 1/rate(CUR) EUR = 1 CUR.
"""
records = self.__db._currency[currency]
return records[0]['rate'] if len(records) > 0 else None
def getAllRates(self):
""" Get all known exchange rates as a dict. """
return [(r['currency'], r['rate']) for r in self.__db]
def getRatesCount(self):
""" Get total number of exchange rates in db. """
return len(self.__db)
示例6: calculatingWeights
# 需要导入模块: from pydblite import Base [as 别名]
# 或者: from pydblite.Base import create_index [as 别名]
def calculatingWeights(graph, nodesnotLinked, database, calculatingFile):
pdb = Base(calculatingFile)
pdb.create('node1', 'node2', 'WCNFTI01','WCNFTI02', 'WCNFTI03','WCNFTI04','WCNFTI05','WCNFTI06','WCNFTI07','WCNFTI08','WCNFTI09','WAAFTI01','WAAFTI02', 'WAAFTI03','WAAFTI04','WAAFTI05','WAAFTI06','WAAFTI07','WAAFTI08','WAAFTI09')
pdb.create_index('node1', 'node2')
element = 0
qtyofNodesToProcess = len(nodesnotLinked)
for pair in nodesnotLinked:
element = element+1
FormatingDataSets.printProgressofEvents(element, qtyofNodesToProcess, "Calculating features for nodes not liked: ")
neighbors_node1 = all_neighbors(graph, pair[0])
neighbors_node2 = all_neighbors(graph, pair[1])
len_neihbors_node1 = len(neighbors_node1)
len_neihbors_node2 = len(neighbors_node2)
CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
WCNFTI01 = 0;
WCNFTI02 = 0;
WCNFTI03 = 0;
WCNFTI04 = 0;
WCNFTI05 = 0;
WCNFTI06 = 0;
WCNFTI07 = 0;
WCNFTI08 = 0;
WCNFTI09 = 0;
WAAFTI01 = 0;
WAAFTI02 = 0;
WAAFTI03 = 0;
WAAFTI04 = 0;
WAAFTI05 = 0;
WAAFTI06 = 0;
WAAFTI07 = 0;
WAAFTI08 = 0;
WAAFTI09 = 0;
for cn in CommonNeigbors:
item = get_partOfWeightCalculating(graph, database, pair, cn)
WCNFTI01 = WCNFTI01 + item['WCN'][0];
WCNFTI02 = WCNFTI02 + item['WCN'][1];
WCNFTI03 = WCNFTI03 + item['WCN'][2];
WCNFTI04 = WCNFTI04 + item['WCN'][3];
WCNFTI05 = WCNFTI05 + item['WCN'][4];
WCNFTI06 = WCNFTI06 + item['WCN'][5];
WCNFTI07 = WCNFTI07 + item['WCN'][6];
WCNFTI08 = WCNFTI08 + item['WCN'][7];
WCNFTI09 = WCNFTI09 + item['WCN'][8];
WAAFTI01 = WAAFTI01 + item['WAA'][0];
WAAFTI02 = WAAFTI02 + item['WAA'][1];
WAAFTI03 = WAAFTI03 + item['WAA'][2];
WAAFTI04 = WAAFTI04 + item['WAA'][3];
WAAFTI05 = WAAFTI05 + item['WAA'][4];
WAAFTI06 = WAAFTI06 + item['WAA'][5];
WAAFTI07 = WAAFTI07 + item['WAA'][6];
WAAFTI08 = WAAFTI08 + item['WAA'][7];
WAAFTI09 = WAAFTI09 + item['WAA'][8];
pdb.insert(str(pair[0]), str(pair[1]), WCNFTI01, WCNFTI02, WCNFTI02,
WCNFTI03,WCNFTI04,WCNFTI05,WCNFTI06,WCNFTI07,WCNFTI08,WCNFTI09,
WAAFTI01, WAAFTI02, WAAFTI02,
WAAFTI03,WAAFTI04,WAAFTI05,WAAFTI06,WAAFTI07,WAAFTI08,WAAFTI09,
)
pdb.commit()
return pdb;
示例7: open
# 需要导入模块: from pydblite import Base [as 别名]
# 或者: from pydblite.Base import create_index [as 别名]
# palavrachaveArquivo = open(palavrachavePath, 'r')
#
# publicacaoPath = '/Mestrado-2016/tabelas_dump/publicacao.csv'
# publicacaoArquivo = open(publicacaoPath, 'r')
#
# autoresPath = '/Mestrado-2016/tabelas_dump/autorpublicacao.csv'
# autoresArquivo = open(autoresPath, 'r')
#
infoPath = '/Mestrado-2016/tabelas_dump/infoImportantes2000_2005.csv'
infoArquivo = open(infoPath, 'w')
infoArquivo.write('idpublication;year;keywords;authors\n')
kdb = Base('/Mestrado-2016/tabelas_dump/palavra.pdl')
kdb.open()
kdb.create_index('idpublicacao')
pdb = Base('/Mestrado-2016/tabelas_dump/publicacao.pdl')
pdb.open()
pdb.create_index('idpublicacao')
adb = Base('/Mestrado-2016/tabelas_dump/autor.pdl')
adb.open()
adb.create_index('idpublicacao')
pub = [r for r in pdb if r['ano'] >= 2000 and r['ano'] <= 2005 ]
i = 0
tamanho = len(pub)
for row in pub:
inicio = datetime.now()