Oct-26-2016, 10:24 PM
Hello,
I do exactly this in some code that I just posted on github today https://github.com/Larz60p/NLTK-Corpora-...oraData.py
There is a good example in fluent python (Luciano Ramalho - O'Reilly page 70)
I do exactly this in some code that I just posted on github today https://github.com/Larz60p/NLTK-Corpora-...oraData.py
There is a good example in fluent python (Luciano Ramalho - O'Reilly page 70)
from collections import defaultdict DIAL_CODES = [(86, 'China'), (91, 'India'), (1, 'United States') ...] country_code = {country: code for code, country in DIAL_CODES}so in your case,
from collections import defaultdict V = [('v1', (1,2)), ('v2', (2,3)), ('v3', (3,1)), ('v4', (4,1)), ('v5', (2,4)), ('v6', (4,5))] Graph = {edge: tup for edge, tup inĀ V}