Need a script to dynamically rewrite URLs of a website. The rewriting will consist of finding the missing levels in a phrase, replacing spaces with hyphens and removing modifiers which we will define. A table will contain all the phrases and the multiple levels it contains. The script will NOT know the phrase it needs to complete and needs to determine using the best match in the table.
Example:
TABLE
------
Phrase A: HP Pavilion DV6
Level 1: Brand = HP
Level 2: Family = Pavilion
Level 3: Model = DV6
Phrase B: HP Pavilion DV6-2000
Level 1: Brand = HP
Level 2: Family = Pavilion
Level 3: Model = DV6-2000
Phrase C: Acer TravelMate 7000
Level 1: Brand = Acer
Level 2: Family = TravelMate
Level 3: Model = 7000
Phrase D: Acer Aspire 7000
Level 1: Brand = Acer
Level 2: Family = Aspire
Level 3: Model = 7000
Phrase E: Acer Aspire One D100
Level 1: Brand = Acer
Level 2: Family = Aspire One
Level 3: Model = D100
Phrase F: HP G62
Level 1: Brand = HP
Level 2: Family = NULL
Level 3: Model = G62
------
MODIFIER
Battery
Adapter
INPUT: HP DV6 Battery
OUTPUT: HP-Pavilion-DV6
INPUT: Pavilion DV6-2000 Adapter
OUTPUT: HP-Pavilion-DV6-2000
INPUT: TravelMate 7000 Battery
OUTPUT: Acer-TravelMate-7000
INPUT: HP G62 Battery
OUTPUT: HP-G62
INPUT: Aspire One D100 Adapter
OUTPUT: Acer-Aspire-One-D100
INPUT: Acer 7000 Battery
OUTPUT: Acer-Aspire-7000 OR Acer-TravelMate-7000
In the last one, since there are two possible choices, the script can randomly choose one. We will provide list of test cases as required.