def createGraph(results):
   
    entities = GdfEntries(Evidence)
    
    counter = 1
    for i in range(0, len(results), 2):
        entities.add_node(Evidence(name = results[i], label = counter, filename = results[i] , timestamp = results[i+1], labelvisible = True))
        counter += 1

    for i in range(0, len(results)-2, 2):
        for j in range(i+2, len(results), 2):
            timestamp1 = results[i+1]
            timestamp2 = results[j+1]       
            if ruleSearchFile.checkTimestamps(timestamp1, timestamp2) == 1:
                entities.link(results[i], results[j], directed = False)
    
    for i in range(0, len(results)-2, 2):
        timestamp1 = results[i+1]
        timestamp2 = results[i+3]
        if ruleSearchFile.checkTimestamps(timestamp1, timestamp2) != 1:
            entities.link(results[i], results[i+2])
    
    print entities.dumps()
    f.write(entities.dumps())
    f.close()
def createGraph(results):

    entities = GdfEntries(Evidence)

    counter = 1
    for i in range(0, len(results), 2):
        entities.add_node(
            Evidence(name=results[i],
                     label=counter,
                     filename=results[i],
                     timestamp=results[i + 1],
                     labelvisible=True))
        counter += 1

    for i in range(0, len(results) - 2, 2):
        for j in range(i + 2, len(results), 2):
            timestamp1 = results[i + 1]
            timestamp2 = results[j + 1]
            if ruleSearchFile.checkTimestamps(timestamp1, timestamp2) == 1:
                entities.link(results[i], results[j], directed=False)

    for i in range(0, len(results) - 2, 2):
        timestamp1 = results[i + 1]
        timestamp2 = results[i + 3]
        if ruleSearchFile.checkTimestamps(timestamp1, timestamp2) != 1:
            entities.link(results[i], results[i + 2])

    print entities.dumps()
    f.write(entities.dumps())
    f.close()
Beispiel #3
0
    for row in reader:

        count += 1
        print(["processing", count])

        party = row['Partido'].decode('utf-8')

        phrase = row['Fala'].decode('utf-8')
        phrase = strip_digits(phrase)
        phrase = sorted(phrase.split(' '))
        phrase = list(map(removePonctuations, phrase))
        phrase = [x.lower() for x in phrase]
        phrase = list(filter(removeWords, phrase))
        phrase = list(filter(None, phrase))

        entities.add_node(Node(name=party, label=party))

        print(phrase)
        for word in phrase:
            entities.add_node(Node(name=word, label=word))
            for other_word in phrase:
                if word != other_word:
                    entities.add_node(Node(name=other_word, label=other_word))
                    link(word, other_word, 0.1)
                    link(party, word, 1)

for k, v in links.iteritems():
    nodes = k.split('_')
    if v > 0.3:
        entities.link(nodes[0], nodes[1], weight=v)
Beispiel #4
0
 def test_entries(self):
     ge = GdfEntries(Product, Edge)
     ge.add_node(Product(name='Somenode', company='Unknown'))
     ge.add_node(Product(name='Otherone', company='Unknown'))
     ge.link('Somenode', 'Otherone', color=(255,0,0))
     ge.dumps()
Beispiel #5
0
 def test_entries(self):
     ge = GdfEntries(Product, Edge)
     ge.add_node(Product(name='Somenode', company='Unknown'))
     ge.add_node(Product(name='Otherone', company='Unknown'))
     ge.link('Somenode', 'Otherone', color=(255, 0, 0))
     ge.dumps()
Beispiel #6
0
            results_queue.put((user_id, foaf['id']))

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Fetch Facebook Network Graph')
    parser.add_argument('token', help='Your facebook access token')
    args = parser.parse_args()

    entries = GdfEntries()

    print 'Fetching your friends...'
    foaf = {}
    friends = get_friends(args.token)
    for count, user in enumerate(friends):
        user_id = user['id']

        node = Node(name=user_id, label=user['name'])
        entries.add_node(node)

    perform_linking = LinkingPerformer(args.token)

    pool = Pool(15)
    pool.map(perform_linking, friends)

    print 'Storing Graph...'
    while not results_queue.empty():
        entries.link(*results_queue.get())

    print 'Saving file friends.gdf...'
    with closing(open('friends.gdf', 'w')) as f:
        entries.dump(f)
    print 'Saved!'