Dr. Inventor Analogically Blended Creativity (DRI-ABC) Framework.

ROS Mapping version 1.0.6

New Features of Version 1.0.6

Important:

When changing the similarity metrics, makes sure that you also clean previous scores from similarity score database. Otherwise, the old metrics and the new metrics will mix up and result inconsistent score.

Full Mapping result

  • driros database Full Databse Dump containing all the mappings [For Interal use Only]
  • Resources

    Prerequisite

    1. Download and configure GenerateROS GenerateROS to access existing ROS or to generate new ROS for your papers.
    2. Put the latest GenerateROS.dll, libcurl.dll and settings.txt under your java project folder.
    3. Make sure mysql is up and running with your username and password. Note that for setting up a new database, you need to have privilege to create a database in your mysql server. For performance improvement turn on mysql database. The library can work without mysql turned on but it will be slower as it calculates similarity directly from WordNet.
    4. Make sure neo4j is up and running with your username and password.
    5. Make sure that you have the paper id of the source and the target papers.
    6. Java jdk 1.6 or latest version installed and running on your machine.

    How to run

    1. Download the jar file from Generate Mapping This file contains the jar file and all the associated dependent files and libraries.
    2. Extract the downloaded file to your preferred location.
    3. In your java project, add the jar file as a library
    4. Put the GenerateROS.dll, libcurl.dll and ROSIneract.properties under your java project folder. Make sure that you have the latest version for each.
    5. If you are a first time user, it is recommended to use the "Example.java" file to run the program.

    How to use the Library to generate mappings

    To run analogy between two papers (in this case ROS), you need to have the neo4j id of the source and the target graphs. To load these graphs into memory you need declare the following classes.
    First, in your main method, create AnalogyMapper class which facilitates loading properties files, setting similarity metrics and selecting rhetorical categories.

    AnalogyMapper mapper = new AnalogyMapper();
    Then, load the settings from the properties file, if you didn't do this already.
    Note: If you already load ROSInteract in your code, doing it the second time will cause a problem.
    mapper.loadROSInteract();
    This method essentially calls the following lines to load the dll file for the ROSInteract component and reads all the settings from the ROSInteract.properties file.

    String classPath = System.getProperty("user.dir");
    System.load(classPath + "\\GenerateROS.dll");
    ros = new ROSInteract(classPath + "\\ROSInteract.properties");


    If you are using a unix system you should replace this method with
    mapper.loadROSInteractUnix();
    If you are running this model for the first time and do not have the similarityscore database created, include the following line. Make sure the user has a privilege to create a new database.
    mapper.setupdb("root", "");
    Choose the WordNet metrics you would like to use here. The default metrics is Lin. Use the WN_METRICS enum to see list of implemented metrics.

    mapper.setSimMetrics(WN_METRICS.LIN);
    mapper.setOverallSimThreshold(0.4F);
    mapper.setAnalogicalSimThreshold(0.1F);
    Define your rhetorical categories. E.g.

    int[] rhetCat = new int[]{RHETORICAL_CATEGORY.ABSTRACT.getValue(), RHETORICAL_CATEGORY.BACKGROUND.getValue()};
    Set the neo4j Ids of the graphs you would like to compare. You have two options to pass the ids.
    1. Passing the two graph ids using the following code with no rhetorical category (uses the full graph). E.g.
      map = mapper.Map(1, 2);
    2. Passing the two graph ids and their rhetorical categories using the following code. E.g.
      map = mapper.Map(1,rhetCatS, 2, rhetCatT); //including the source and the target rhetorical category you want.
    Loading multiple graphs into memory and running mapping from graphs loaded in memory. In memory graph speeds up things when you have large memory. It avoids repetitive calls to the neo4j server and it loads the required graph into memory only once.
    1. First create two arrays of neo4j graph id and populate your graph ids in the source and the target arrays respectively. E.g.
        int sourceSize = 10;
              int[] sGraphIds = new int[sourceSize];
              for (int i = 0; i < sourceSize; i++) {
                  sGraphIds[i] = i + 1;
              }
              int targetSize = 10;          
              int targetStart = 0;
              int[] tGraphIds = new int[targetSize];
              for (int i = 0; i < targetSize; i++) {
                  tGraphIds[i] = targetStart + i + 1;
              }
                                      
    2. Second load the graphs into memory using the following code.
      StringBuilder result = new StringBuilder("");
              //load your graph in memory here.
              mapper.loadInMemoryGraph(sGraphIds, rhetCatS, tGraphIds, rhetCatT);
              ROSGraph G1 = null, G2 = null;
                                      
    3. Using the following code get a reference to the loaded graph.
      ROSGraph[] inMemoryGraph = mapper.getInMemoryGraph();
    4. Using the following map to retrieve the source and the target graph index, iterate through each target and source to map all the source graphs to all the target graphs. See the example provided for details of the code.

      //here you can pass any combination of the source and the target.  But make sure that you use the correct array index corresponding to 
              //the graph id you are interested in. You may use the sMap ant tMap which are Map objects between array index and neo4jid.
              for (Integer entry : mapper.getTmap().keySet()) {
                  result.append(map.getMetricsHeader()).append("\n");
                  //System.out.println("Entry is "+ entry +"\t neoid="+ mapper.getTmap().get(entry));
                  try {
                      G2 = mapper.getInMemoryGraph()[entry];
                      for (Integer sentry : mapper.getSmap().keySet()) {
                          G1 = mapper.getInMemoryGraph()[sentry];
                          map = mapper.generateMapping(G1, G2);
      
                          if (map.getOverallSimilarity() >= mapper.getOverallSimThreshold()) {
                              result.append(map.getMetrics()).append(",").append(mapper.getTriples().getInferredTriples().size()).append("\n");
                              db.writeMapingResults(G1.getGraphId(), rhetCatS, G2.getGraphId(), rhetCatT, map.getAnalogicalSimilarity(), 0,
                                      map.getInferenceCount(), map.getOverallSimilarity(), map.getMapInJSON(), mapper.getTriples().toJson());
      
                          }
                          /// System.out.println(map.getMetrics() + "," + mapper.getTriples().getInferredTriples().size() + "\n");
                          G1 = null;
                      }
                      String fileName = "C:\\DRINVENTOR_PROJECT\\Complet-Experiment-Setups\\CASAEvaluation\\Experiment1\\" + G2.getGraphId() + ".csv";
                      FileWriter fw = new FileWriter();
                      fw.writeToFile(fileName, result.toString());
                      G2 = null;
                      result.setLength(0);
      
                  } catch (Exception e) {
                      System.out.println("There is a problem mapping graph:: " + entry);
                      e.printStackTrace();
                  }
              }
                                      
    Call generateMapping(ROSGraph,ROSGraph) by passing your source and target graph in that order.E.g.

    map = mapper.generateMapping(G1, G2);
    G1 is the source graph and G2 is the target graph. Switching this order will result a different mapping.
    You can get all the information contained in the map using the methods defined by the ROSMap class. For Example,

    map.getMapSize(); // to get the mapping size
    map.getAnalogicalSimilarity(); // to get the analogical similarity value
    map.getMappingNodePairs().get(0).getSourceNodeId();// to get the first mapping pair's source node id.
    map.getMappingNodePairs().get(0).getTargetNodeId(); // to get the first mapping pair's target node id.
    map.getMappingNodePairs().get(0).getSimScore();// to get the first mapping pair's similarity score.
    map.getMappingNodePairs().get(0).isVisible();//// to get whether this pair needs to be visible.
    You can extract the mapping results in different formats.

    JSON Format
    System.out.println(bestmap.getMapInJSON());
    CSV Format
    System.out.println(bestmap.getMapInCSV());
    Metrics
    System.out.println(map.getMetrics());
    If you decide to directly interact with the mapping classes and methods without using the mapper class, please see the source code for the AnalogyMapper class provided. In addition to this documentation of each class provided should guide you to write your own application of analogy mapping.

    How to report bugs

    This is an initial implementation and by no means is complete. We expect more comments and bug reports from other groups. Please report any bug or forward your questions to abgaz.yalemisew@nuim.ie or report it on redmine.

    Previous versions

    Click here For previous versions.
    Last updated May 04, 2016
    This research project receives funding from the European Commission Seventh Framework Programme. Activity ICT (FP7-ICT-2013.8.1), Grant agreement no: 611383.