Changeset 3014 for WAeUP_SRP/base/skins


Ignore:
Timestamp:
11 Jan 2008, 20:18:17 (17 years ago)
Author:
joachim
Message:

WAeUP LGA Widget uses new algorithm
ti_441_resolve_part1 + part2 also
part2 can now be used to rename lgas, a list of all not found lgas is
printed at the end.

Location:
WAeUP_SRP/base/skins/waeup_utilities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_utilities/ti_441_resolve_part1.py

    r3009 r3014  
    5757    jamb_lga = getattr(getattr(students_folder,student_record.id),'application').getContent().jamb_lga
    5858    words = ' '.join((jamb_state, jamb_lga))
    59     words = re_split('[^a-zA-Z0-9/]',words)
    60     lga_words = []
    61     for word in words:
    62         if word:
    63             lga_words += word.lower(),
    64     lga_words.sort()
    65     state_lga = ''
    66     while not state_lga:
    67         for k,l in words_dict.items():
    68             if lga_words == l:
    69                 state_lga = k
    70                 break
    71         break
     59    # words = re_split('[^a-zA-Z0-9/]',words)
     60    # lga_words = []
     61    # for word in words:
     62    #     if word:
     63    #         lga_words += word.lower(),
     64    # lga_words.sort()
     65    # state_lga = ''
     66    # while not state_lga:
     67    #     for k,l in words_dict.items():
     68    #         if lga_words == l:
     69    #             state_lga = k
     70    #             break
     71    #     break
     72    state_lga = context.waeup_tool.findLga(words,words_dict)
    7273    if state_lga:
    7374        msg = "found %s is %s for %s " % (state_lga,student_record.lga,student_record.id)
     
    7879            logger.info("found %d to correct state/lga combinations of %d so far" % (len(d),count))
    7980    else:
    80         msg = "no '%s' for %s" % (lga_words,student_record.id)
     81        msg = "no '%s' for %s" % (words,student_record.id)
    8182        logger.info(msg)
    8283        #rwrite(msg)
  • WAeUP_SRP/base/skins/waeup_utilities/ti_441_resolve_part2.py

    r2997 r3014  
    6262#     return (d,states,lgas)
    6363
    64 difference = context.waeup_tool.difference
     64#difference = context.waeup_tool.difference
    6565re_split = context.waeup_tool.re_split
    6666#logger.info('')
     
    6969logger.info("found %d students" % total)
    7070count = 0
     71correctable = wrong = 1
    7172commit_after = 100
    7273logger.info('started to fix %d records in students_catalog' % total)
     
    7677words_dict = mapping['word_dict']
    7778d = {}
     79not_found_lgas = []
     80not_found_count = {}
     81rename_lgas = {}
     82rename_lgas['edo_orhionmwon'] = 'edo_ohionmwon'
    7883for student_record in student_records:
    7984    # skip record without lga value
     
    8792        continue
    8893    #rwrite("%s: %s" % (student_record.id,student_record.lga))
     94    if student_record.lga in rename_lgas.keys():
     95        correctable += 1
     96        d[student_record.id] = rename_lgas[student_record.lga]
     97        if len(d) and not len(d)  % commit_after:
     98            logger.info("found %d to correct state/lga combinations of %d so far" % (len(d),count))
     99        continue
    89100    words = student_record.lga
    90101    if len(words.split(' / ')) == 2:
    91102        words = words.replace(' / ',' ')
    92     words = re_split('[^a-zA-Z0-9/]',words)
    93     lga_words = []
    94     for word in words:
    95         if word:
    96             lga_words += word.lower(),
    97     lga_words.sort()
    98     # state = sl[0].lower().strip()
    99     # state = '_'.join(state.split())
    100     # lga = sl[1].lower().strip()
    101     # if not lga or not state:
    102     #     logger.info("found invalid lga %s of %s" % (student_record.lga,student_record.id))
    103     #     continue
    104     state_lga = ''
    105     while not state_lga:
    106         for k,l in words_dict.items():
    107             if lga_words == l:
    108                 state_lga = k
    109                 break
    110         break
     103    state_lga = context.waeup_tool.findLga(words,words_dict)
    111104    if state_lga:
    112105        if state_lga != student_record.lga:
     106            correctable += 1
    113107            msg = "found %s is %s for %s " % (state_lga,student_record.lga,student_record.id)
    114108            #rwrite(msg)
     
    119113            msg = "already corrected %s : %s for %s " % (state_lga,student_record.lga,student_record.id)
    120114    else:
    121         msg = "no '%s' for %s" % (lga_words,student_record.id)
     115        wrong += 1
     116        msg = "no '%s' for %s" % (words,student_record.id)
     117        if len(words) > 2:
     118            if words not in not_found_lgas:
     119                not_found_lgas += words,
     120                not_found_count[words] = 1
     121            else:
     122                nfc = not_found_count[words]
     123                nfc += 1
     124                not_found_count[words] = nfc
     125        #rwrite(msg)
    122126    # if count > 2000:
    123127    #     break
     128not_found_lgas.sort()
     129for lga in not_found_lgas:
     130    msg = "not found %s count: %d" % (lga,not_found_count[lga])
     131    logger.info(msg)
    124132to_edit = len(d)
    125 logger.info("found %d correct state/lga combinations of %d" % (to_edit,count))
    126 
     133logger.info("found %d correctable state/lga combinations, not correctable %d total %d" % (correctable,
     134                                                                                          wrong,
     135                                                                                          count))
    127136edited = 1
    128137for student_id,lga in d.items():
Note: See TracChangeset for help on using the changeset viewer.