paddinglist = ('# ' * (n//2)) fullwordlist[:0] = paddinglist fullwordlist.extend(paddinglist) ngrams = dh.getNGrams(fullwordlist, n) worddict = dh.nGramsToKWICDict(ngrams) # create tag cloud cloudsize = 40 maxfreq = sorteddict[0][0] minfreq = sorteddict[cloudsize][0] freqrange = maxfreq - minfreq tempstring = '' resorteddict = dh.reSortFreqDictAlpha(sorteddict[:cloudsize]) for k in resorteddict: kfreq = k[0] klabel = dh.undecoratedHyperlink('#'+k[1], k[1]) scalingfactor = (kfreq - minfreq) / float(freqrange) tempstring += dh.scaledFontSizeSpan(klabel, scalingfactor) outstring = dh.defaultCSSDiv(tempstring) + '<br />' # create KWIC listings for each item for k in resorteddict: klabel = k[1] tempstring = '' tempstring += '<a name=\"%s\">%s</a> ' % (klabel, klabel) tempstring += dh.undecoratedHyperlink('#', '[back]') outstring += dh.defaultCSSDiv(tempstring, opt='font-size : 24px;') outstring += '<p><pre>' for t in worddict[klabel]: outstring += dh.prettyPrintKWIC(t) outstring += '<br />'
biodict[bioid] = dh.normalizeFrenchAccents(bioname) # make directory to store downloaded pages if one doesn't exist if os.path.exists('iroquois') == 0: os.mkdir('iroquois') # download a local copy of each bio urlprefix = 'http://www.biographi.ca/EN/ShowBioPrintable.asp?BioId=' for b in biodict: print "Processing bioid: " + str(b) url = urlprefix + str(b) outfile = 'iroquois/dcb-' + str(b) + '.html' if os.path.isfile(outfile) == 0: response = urllib2.urlopen(url) html = response.read() f = open(outfile, 'w') f.write(html) f.close time.sleep(2) else: print "File already downloaded" sys.stdout.flush() # create a page of links to local copies outstring = '' for b in biodict: outfile = 'dcb-' + str(b) + '.html' outstring += dh.undecoratedHyperlink('iroquois/'+outfile, str(b)) outstring += ' ' * 4 outstring += biodict[b] outstring += "<br />" dh.wrapStringInHTML("get-iroquois-bios", searchresultfile, outstring)