Example #1
0
def extractQuadrasLexGraphIndexFromApostaFile(apostaFilename, EQUALSN=4):
  quadrasDict = {}; apostaFile = open(apostaFilename)
  import combinadics
  line = apostaFile.readline(); c=0
  while line:
    dezenas = dezenasIntFromTextLine(line)
    if dezenas == None:
      line = apostaFile.readline()
      continue
    c+=1
    if EQUALSN == 4:
      quadras    = getQuadrasFromDezenasList(dezenas)
    elif EQUALSN == 5:
      quadras    = getQuinasFromDezenasList(dezenas)
    # lgi6 = combinadics.findIndexFromCombination(dezenas)
    print c,#'::', dezenas, 'len dict', len(quadrasDict)
    for quadra in quadras:
      lexGraphIndex = combinadics.findIndexFromCombination(quadra, EQUALSN)
      try:
        quadrasDict[lexGraphIndex] += 1
      except KeyError:
        quadrasDict[lexGraphIndex] = 1
      #print quadra, lexGraphIndex, 'q=%d' %(quadrasDict[lexGraphIndex])
      print '%2d' %(quadrasDict[lexGraphIndex]),
    print
    line = apostaFile.readline()
  indices = quadrasDict.keys()
  print 'len', len(quadrasDict)
Example #2
0
 def findIndexFromCombination(self):
   import combinadics
   return combinadics.findIndexFromCombination(self.getDezenas())