Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. pattern/string matching algorithm

pattern/string matching algorithm

Scheduled Pinned Locked Moved Algorithms
regexdatabasealgorithmsjsonhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    asdf23211
    wrote on last edited by
    #1

    I think this should be common problem in Computer science. I have a data like this

    List>> Qdata = new ArrayList>>();//QUERY
    List>> Tdata = new ArrayList>>();//TARGET

    List Qg1 = Arrays.asList("C", "A", "PC", "R");
    List Qg2 = Arrays.asList("DQ", "EQ", "KC", "AC");
    List Qg3 = Arrays.asList("KQ", "AT");
    List Qg4 = Arrays.asList("KQ", "AT", "DQ", "KC","AC","KQ", "AT", "KC","AC","KQ", "AT", "DQ", "KC","AC");
    List Qg5 = Arrays.asList("KQ", "AT", "DQ", "KC","AC");
    List Qg6 = Arrays.asList("KQ", "AT", "DQ", "KC","AC");
    List Qg7 = Arrays.asList("AC","KQ", "AT","AT", "DQ", "KC","AC");
    
    Map\> Qmap = new HashMap\>();
    Qmap.put(1, Qg1);
    Qmap.put(2, Qg2);
    Qmap.put(3, Qg3);
    Qmap.put(4, Qg4);
    Qmap.put(5, Qg5);
    Qmap.put(6, Qg6);
    Qmap.put(7, Qg7);
    
    
    List Tg1 = Arrays.asList("C", "A", "PC", "?");
    List Tg2 = Arrays.asList("KQ", "AT","DQ", "EQ", "KC", "AC");
    List Tg3 = Arrays.asList("AT", "DQ", "KC","AC");
    List Tg4 = Arrays.asList("KQ", "AT", "DQ", "KC","AC","KQ", "AT", "KC","AC");
    List Tg5 = Arrays.asList("KQ", "AT", "DQ", "KC","AC");
    List Tg6 = Arrays.asList("KQ", "AT", "DQ", "KC","AC");
    List Tg7 = Arrays.asList("AT","AT", "DQ", "KC","AC");
    List Tg8 = Arrays.asList("AC");
    List Tg9 = Arrays.asList("ACL","AC","C","A","PC");
    
    Map\> Tmap = new HashMap\>();
    Tmap.put(1, Tg1);
    Tmap.put(2, Tg2);
    Tmap.put(3, Tg3);
    Tmap.put(4, Tg4);
    Tmap.put(5, Tg5);
    Tmap.put(6, Tg6);
    Tmap.put(7, Tg7);
    Tmap.put(8, Tg8);
    Tmap.put(9, Tg9);
    
    Qdata.add(Qmap);
    Tdata.add(Tmap)
    

    want to match Qdata with Tdata, the tricky part here is, if you observe the data Qg3+Qg2 forms Tg2 Tg4+Tg3 forms Qg4 with "kQ" missing between Tg4 and Tg3 Tg8+Tg9 forms Qg7 and with the rest, it is pretty straight forward. I don't know how to deal with this tricky part. I used map to store the data because it is more desired for the algorithm to finds matching in the same position in Tdata and Qdata like Qg5 has a complete match with Tg5 Qg6 has a complete match with Tg6 The final ideal output that I expect in this case is: Qg1 matches with Tg1

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups