hharte / mm_manager

Manager for the Nortel Millennium series of payphones.
Other
60 stars 10 forks source link

Utility "generate_lcd.py" Returning Ratecenters Based On Partial String Match #6

Closed wmactor closed 4 years ago

wmactor commented 4 years ago

Problem Description:

When generating tables using generate_lcd.py, I found that the program was creating erroneous tables for partial string matches of the specified ratecenter in the command line - for example, specifying Country = Canada, NPA = 416 and ratecenters = Toronto and Caledon returned ratecenters of Caledonia and New Caledonia, located well outside the Toronto local calling area (for example, in area codes 782 and 902 in Nova Scotia).

A Suggested Fix, For Your Review:

I asked my son James to have a look at it, and he revised the code on Line 102 as follows below. The program now returns only ratecenters that exactly match the entered request :

Original code:

rc = sc[sc['RateCenter'].str.match('|'.join(args.ratecenters))]

Revised code:

def prepRateForRegex(r): return r'^' + r + '$'

rate_centers = map(prepRateForRegex,args.ratecenters) rc = sc[sc['RateCenter'].str.match('|'.join(rate_centers))]

Program Output:

Tables Generated With The Existing Code:

LCD Table Generator for the Nortel Millennium Payphone (c) 2020, Howard M. Harte

Terminal NPA: 416 Reading CA data from COCodeStatus_ALL.csv Rate Centers: ['Toronto', 'Caledon'] NPAs for these rate centers: ['416', '226', '289', '365', '437', '519', '647', '782', '902', '905'] Generating double-compressed LCD table mm_table_88.bin for NPA 416. Generating double-compressed LCD table mm_table_89.bin for NPA 226. Generating double-compressed LCD table mm_table_8a.bin for NPA 289. Generating double-compressed LCD table mm_table_8b.bin for NPA 365. Generating double-compressed LCD table mm_table_8c.bin for NPA 437. Generating double-compressed LCD table mm_table_8d.bin for NPA 519. Generating double-compressed LCD table mm_table_8e.bin for NPA 647. Generating double-compressed LCD table mm_table_8f.bin for NPA 782. Generating double-compressed LCD table mm_table_90.bin for NPA 902. Generating double-compressed LCD table mm_table_91.bin for NPA 905. Successfully completed generating LCD tables.

Tables Generated With The Modified Code:

LCD Table Generator for the Nortel Millennium Payphone (c) 2020, Howard M. Harte

Terminal NPA: 416 Reading CA data from COCodeStatus_ALL.csv Rate Centers: ['Toronto', 'Caledon'] NPAs for these rate centers: ['416', '226', '437', '519', '647'] Generating double-compressed LCD table mm_table_88.bin for NPA 416. Generating double-compressed LCD table mm_table_89.bin for NPA 226. Generating double-compressed LCD table mm_table_8a.bin for NPA 437. Generating double-compressed LCD table mm_table_8b.bin for NPA 519. Generating double-compressed LCD table mm_table_8c.bin for NPA 647. Successfully completed generating LCD tables.

The revised python file is attached for your review.

Regards,

Wayne

revised generate_lcd.zip

hharte commented 4 years ago

Thanks Wayne, I merged the change from your son.

Take care, Howard

On Tue, Aug 25, 2020 at 11:14 AM wmactor notifications@github.com wrote:

Problem Description:

When generating tables using generate_lcd.py, I found that the program was creating erroneous tables for partial string matches of the specified ratecenter in the command line - for example, specifying Country = Canada, NPA = 416 and ratecenters = Toronto and Caledon returned ratecenters of Caledonia and New Caledonia, located well outside the Toronto local calling area (for example, in area codes 782 and 902 in Nova Scotia).

A Suggested Fix, For Your Review:

I asked my son James to have a look at it, and he revised the code on Line 102 as follows below. The program now returns only ratecenters that exactly match the entered request :

Original code:

rc = sc[sc['RateCenter'].str.match('|'.join(args.ratecenters))]

Revised code:

def prepRateForRegex(r): return r'^' + r + '$'

rate_centers = map(prepRateForRegex,args.ratecenters) rc = sc[sc['RateCenter'].str.match('|'.join(rate_centers))]

Program Output:

Tables Generated With The Existing Code:

LCD Table Generator for the Nortel Millennium Payphone (c) 2020, Howard M. Harte

Terminal NPA: 416 Reading CA data from COCodeStatus_ALL.csv Rate Centers: ['Toronto', 'Caledon'] NPAs for these rate centers: ['416', '226', '289', '365', '437', '519', '647', '782', '902', '905'] Generating double-compressed LCD table mm_table_88.bin for NPA 416. Generating double-compressed LCD table mm_table_89.bin for NPA 226. Generating double-compressed LCD table mm_table_8a.bin for NPA 289. Generating double-compressed LCD table mm_table_8b.bin for NPA 365. Generating double-compressed LCD table mm_table_8c.bin for NPA 437. Generating double-compressed LCD table mm_table_8d.bin for NPA 519. Generating double-compressed LCD table mm_table_8e.bin for NPA 647. Generating double-compressed LCD table mm_table_8f.bin for NPA 782. Generating double-compressed LCD table mm_table_90.bin for NPA 902. Generating double-compressed LCD table mm_table_91.bin for NPA 905. Successfully completed generating LCD tables.

Tables Generated With The Modified Code:

LCD Table Generator for the Nortel Millennium Payphone (c) 2020, Howard M. Harte

Terminal NPA: 416 Reading CA data from COCodeStatus_ALL.csv Rate Centers: ['Toronto', 'Caledon'] NPAs for these rate centers: ['416', '226', '437', '519', '647'] Generating double-compressed LCD table mm_table_88.bin for NPA 416. Generating double-compressed LCD table mm_table_89.bin for NPA 226. Generating double-compressed LCD table mm_table_8a.bin for NPA 437. Generating double-compressed LCD table mm_table_8b.bin for NPA 519. Generating double-compressed LCD table mm_table_8c.bin for NPA 647. Successfully completed generating LCD tables.

The revised python file is attached for your review.

Regards,

Wayne

revised generate_lcd.zip https://github.com/hharte/mm_manager/files/5125482/revised.generate_lcd.zip

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hharte/mm_manager/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACAT7FJIWELLN3SEMZ24MTSCP5PLANCNFSM4QK6FTIA .