Exemple #1
0
def main():
    parser = argparse.ArgumentParser(description='command line interface for map2annotation')
    parser.add_argument('--type-mapping',dest='type_mapping_file')
    parser.add_argument('--field-mapping', dest='field_mapping_file')
    parser.add_argument('--project-list', dest='projects', help='project_nameA,project_nameB,...')
    args = parser.parse_args()
    if args.type_mapping_file is None and args.field_mapping_file is None:
        print "error, required at least one mapping file to be indicated."
        parser.print_help()
        sys.exit(1)

    project_list = common.get_project_list()

    if args.projects:
        arg_projects = args.projects.split(',')
        project_list = [project for project in project_list if project in arg_projects]

    pa2checker.revert_checker_source()
    
    if not args.type_mapping_file is None:
        type_mappings_to_rules(args.type_mapping_file)

    if not args.field_mapping_file is None:
        field_mappings_to_annotation(project_list, args.field_mapping_file)

    for project in project_list:
        run_anno_inference(project)
def main():
	
  parser = argparse.ArgumentParser()

  parser.add_argument("-c", "--cluster", type=str, help="path to the input json file that contains the clustering information.")
  parser.add_argument("-d", "--dir", type=str, required=True, help="output folder.")
  parser.add_argument("-p", "--plist", type=str, help="a comma separated list of projects to work with.")
  parser.add_argument("-k", "--kernel", action="store_true", help="recompute kernel vectors.")
  parser.add_argument("-g", "--graph", action="store_true", help="regenerate graphs.")
  parser.add_argument("-s", "--sim", type=str, help="specify a subset of projects for finding similar programs in the list of projects.")

  args = parser.parse_args()

  common.mkdir(args.dir)

  # determine which projects to consider
  project_list = common.get_project_list()
  if args.plist:
    arg_projects = args.plist.split(',')
    project_list = [project for project in project_list if project in arg_projects]

  # determine if need to regerenate graphs
  if args.graph:
    for project in project_list:
      generate_graphs(project)
    print("\n***** Done with generating graphs. *****\n") 

  # determine if need to recompute the kernel vectors
  if args.kernel:
    for project in project_list:
      generate_project_kernel(project, args.cluster)
    print("\n***** Done with computing kernels. *****\n")

  # check similarity
  dot_method_map = get_method_map(project_list, False)
  print("Done gathering all method-dot pairs.")
  if args.sim:
    project_sublist = args.sim.split(',')
    for project in project_sublist:
      if project not in project_list:
        print("Skipping {0} since it is not in the list of projects.".format(project))
      else:
        print("Computing similar programs for {0}:".format(project))
        result_file = os.path.join(common.WORKING_DIR, args.dir, project+"_result.txt")
        kernel_file = os.path.join(common.WORKING_DIR, args.dir, project+"_kernel.txt")
        json_file = os.path.join(common.WORKING_DIR, args.dir, project+"_result.json") 
        check_similarity(project, result_file, kernel_file, dot_method_map, json_file, args.cluster, min(5,len(project_list)))
  else:
    for project in project_list:
      pl = list(project_list) # create a copy
      pl.remove(project)
      gather_kernels(pl, os.path.join(common.WORKING_DIR, args.dir, project+"_kernel.txt"))
      print("Computing similar programs for {0}:".format(project))
      result_file = os.path.join(common.WORKING_DIR, args.dir, project+"_result.txt")
      kernel_file = os.path.join(common.WORKING_DIR, args.dir, project+"_kernel.txt")
      json_file = os.path.join(common.WORKING_DIR, args.dir, project+"_result.json") 
      check_similarity(project, result_file, kernel_file, dot_method_map, json_file, args.cluster, min(5,len(project_list)))
  print("\n***** Done with computing similar programs. *****\n")
def main():
  kf = open("corpus_kernel.txt", "w")
  for project in common.get_project_list():
    print "Analyzing {}".format(project)
    project_kernel_file = add_project_to_corpus(project)
    with open(project_kernel_file, "r") as fi: kf.write(fi.read())
    dtrace = get_dtrace_file_for_project(project)
    if dtrace:
      print "Generated {}".format(dtrace)
  kf.close()
def main():
    kf = open("corpus_kernel.txt", "w")
    for project in common.get_project_list():
        print "Analyzing {}".format(project)
        project_kernel_file = add_project_to_corpus(project)
        with open(project_kernel_file, "r") as fi:
            kf.write(fi.read())
        dtrace = get_dtrace_file_for_project(project)
        if dtrace:
            print "Generated {}".format(dtrace)
    kf.close()
Exemple #5
0
def main():
    project_list = common.get_project_list()

    parser = argparse.ArgumentParser()

    parser.add_argument("-rc",
                        "--recompute_clusters",
                        action="store_true",
                        help="recompute clustering for selected projects")
    parser.add_argument(
        "-c",
        "--cluster",
        type=str,
        help="path to the json file that contains clustering information")
    parser.add_argument("-g",
                        "--graph",
                        action="store_true",
                        help="set to regenerate graphs from the programs")
    parser.add_argument("-d",
                        "--dir",
                        type=str,
                        required=True,
                        help="The output directory")
    parser.add_argument("-p",
                        "--projectset",
                        type=str,
                        help="A project set name to work on")
    args = parser.parse_args()

    if args.projectset:
        project_list = common.get_corpus_set(args.projectset)

    args.dir = os.path.abspath(
        os.path.join(common.WORKING_DIR, 'results', args.dir))

    if os.path.exists(args.dir):
        rotate_log_dir(args.dir)

    common.mkdir(args.dir)
    common.set_output_dir(args.dir)
    kernel_dir = os.path.join(args.dir, "kernel_directory")
    common.mkdir(kernel_dir)

    backend.run(project_list, args, kernel_dir)
    print("\n********* END OF BACKEND **********\n")
    frontend.run(project_list, args, kernel_dir)

    collect_stray_output(project_list, args.dir)
    sanity.check_run(project_list, args.dir)
Exemple #6
0
def main():
  project_list = common.get_project_list()

  parser = argparse.ArgumentParser()

  
  parser.add_argument("-rc", "--recompute_clusters", action="store_true", help="recompute clustering for selected projects")
  parser.add_argument("-c", "--cluster", type=str, help="path to the json file that contains clustering information")
  parser.add_argument("-g", "--graph", action="store_true", help="set to regenerate graphs from the programs")
  parser.add_argument("-d", "--dir", type=str, required=True, help="The output directory")
  parser.add_argument("-p", "--projects", type=str, help="A comma separated list of projects to work with.")
  args = parser.parse_args()

  if args.projects:
    arg_projects = args.projects.split(',')
    project_list = [project for project in project_list if project in arg_projects]

  common.mkdir(args.dir)
  kernel_dir = "kernel_directory"
  common.mkdir(kernel_dir)

  backend.run(project_list, args, kernel_dir)
  print("\n********* END OF BACKEND **********\n")
  frontend.run(project_list, args, kernel_dir)
Exemple #7
0
  INPUT: k_list_of_methods
  OUTPUT: patch file for the ontology. Worst case: just add the 'best' implementation
  found in the corpus as a blob to the ontology. Best case: generate an equivalent
  flow-graph in the ontology.
  """
    #print "TODO" # ALL


# if not os.path.isfile(daikon_jar):
#   print "Downloading dependencies"
#   cmd = ["./fetch_dependencies.sh"]
#   run_command(cmd)
#   print "Done."

if __name__ == '__main__':
    corpus = common.get_project_list()
    annotations = {"Sequence": ['java.util.List', 'java.util.LinkedHashSet']}
    top_k = 3
    if len(sys.argv) > 1:
        annotations_file = sys.argv[1]
        if len(sys.argv) > 2:
            top_k = sys.argv[2]
        with open(annotations_file, 'r') as f:
            annotations.clear()
            for line in f.readlines():
                pair = [x.strip() for x in line.split(',')]
                if len(pair) != 2:
                    print("Ignoring {}".format(line))
                    continue
                if pair[0] not in annotations:
                    annotations[pair[0]] = []
Exemple #8
0
import backend, common

project_list = common.get_project_list()
backend.run2(project_list)

  """
  Close the loop and add the best implementation found in the previous
  step back to the ontology.
  INPUT: k_list_of_methods
  OUTPUT: patch file for the ontology. Worst case: just add the 'best' implementation
  found in the corpus as a blob to the ontology. Best case: generate an equivalent
  flow-graph in the ontology.
  """
  print "TODO" # ALL



# if not os.path.isfile(daikon_jar):
#   print "Downloading dependencies"
#   cmd = ["./fetch_dependencies.sh"]
#   run_command(cmd)
#   print "Done."

if __name__ == '__main__':
  corpus = common.get_project_list()
  if len(sys.argv)>1:
    filtered_corpus = []
    for arg in sys.argv[1:]:
      if arg in corpus:
        filtered_corpus += [arg]
    print ("Filtered corpus contianing: {}".format(','.join(filtered_corpus)))
    corpus = filtered_corpus

  annotations = { "Sequence": ['java.util.List', 'java.util.LinkedHashSet'] }
  main(corpus, annotations)