} cs_local_vars_mapping = { **cs_local_vars_mapping, **global_vars_mapping } processed_cs_code = iterate_function_node_to_get_text( "cs", block_cs_node, processed_cs_code, cs_parent_map, cs_local_vars_mapping, cs_global_vars_mapping, cs_object_method_mapping, cs_package_object_mapping, cs_third_party_object_method_mapping_list, cs_third_party_package_object_mapping_list) processed_cs_code = processed_cs_code.replace( "@", "") processed_cs_code = remove_empty_intext( processed_cs_code) # processed_cs_code = keep_only_method_api(processed_cs_code) processed_cs_code = keep_only_cs_sdk_method_api( processed_cs_code) print(cs_function_name_origin + "-----------" + str(processed_cs_code)) if processed_cs_code: with open( "./sentences/cs_functions_sdk_api_sequences.txt", "a") as out: out.write(processed_cs_code + "\n") except Exception as e: print("Excetion in cs part : " + str(e))
cs_function_name_origin = node.text cs_function_name = node.text.lower() processed_cs_code = "" cs_function_block = find_biggest_block(block_cs_node) cs_decl_stmt_locals = list() cs_decl_stmt_locals = iterate_to_get_node_with_type(cs_function_block,"decl_stmt",cs_decl_stmt_locals) cs_local_vars_mapping = get_information_of_decl_stmts(cs_decl_stmt_locals) cs_decl_params = list() cs_decl_params = iterate_to_get_node_with_type(parameter_list_node, "decl", cs_decl_params) cs_param_function_vars_mapping = get_information_of_decl(cs_decl_params) cs_local_vars_mapping = {**cs_local_vars_mapping,**cs_param_function_vars_mapping} cs_local_vars_mapping = {**cs_local_vars_mapping,**cs_global_vars_mapping} processed_cs_code = iterate_function_node_to_get_text("cs",block_cs_node,processed_cs_code,cs_parent_map,cs_local_vars_mapping,cs_global_vars_mapping,cs_object_method_mapping,cs_package_object_mapping,cs_third_party_object_method_mapping_list,cs_third_party_package_object_mapping_list,candidate_sdk_packages) processed_cs_code = processed_cs_code.replace("@","") processed_cs_code = remove_uncessary_tokens(processed_cs_code) processed_cs_code = remove_empty_intext(processed_cs_code) # processed_cs_code = keep_only_method_api(processed_cs_code) # processed_cs_code = keep_only_cs_sdk_method_api(processed_cs_code,cs_keywords) splits = processed_cs_code.split(" ") if len(splits) > 2: # print(cs_function_name_origin + "-----------" + str(processed_cs_code)) if processed_cs_code: with open("./sentences/cs_functions_sdk_api_sequences_all_tokens.txt","a") as out: out.write(processed_cs_code + "\n") except Exception as e: print("Excetion in cs part : " + str(e))
processed_java_code = iterate_function_node_to_get_text( "java", block_java_node, processed_java_code, java_parent_map, java_local_vars_mapping, java_global_vars_mapping, java_object_method_mapping, java_package_object_mapping, java_third_party_object_method_mapping_list, java_third_party_package_object_mapping_list, candidate_sdk_packages) processed_java_code = processed_java_code.replace( "@", "") processed_java_code = remove_uncessary_tokens( processed_java_code) processed_java_code = remove_empty_intext( processed_java_code) # processed_java_code = keep_only_method_api(processed_java_code) # print(processed_java_code) # processed_java_code = keep_only_java_sdk_method_api(processed_java_code,java_keywords) splits = processed_java_code.split(" ") if len(splits) > 3: # print(java_function_name + "-----------" + processed_java_code) with open( "sentences_gson/java_functions_gson_api_sequences_all_tokens_DATA_1.txt", "a") as out: # line = java_path + ";" + java_function_name_origin + ";" + processed_java_code out.write(processed_java_code + "\n") except Exception as e: print("Excetion in java part : " + str(e))
if tag3 == "name": java_function_name_origin = node2.text java_function_name = node2.text.lower() processed_java_code = "" java_function_block = find_biggest_block(block_java_node) java_decl_stmt_locals = list() java_decl_stmt_locals = iterate_to_get_node_with_type(java_function_block,"decl_stmt",java_decl_stmt_locals) java_local_vars_mapping = get_information_of_decl_stmts(java_decl_stmt_locals) java_decl_params = list() java_decl_params = iterate_to_get_node_with_type(parameter_list_node, "decl", java_decl_params) java_param_function_vars_mapping = get_information_of_decl(java_decl_params) java_local_vars_mapping = {**java_local_vars_mapping,**java_param_function_vars_mapping} java_local_vars_mapping = {**java_local_vars_mapping,**global_vars_mapping} processed_java_code = iterate_function_node_to_get_text("java",block_java_node,processed_java_code,java_parent_map,java_local_vars_mapping,java_global_vars_mapping,java_object_method_mapping,java_package_object_mapping,java_third_party_object_method_mapping_list,java_third_party_package_object_mapping_list) processed_java_code = processed_java_code.replace("@","") processed_java_code = remove_empty_intext(processed_java_code) # processed_java_code = keep_only_method_api(processed_java_code) processed_java_code = keep_only_java_sdk_method_api(processed_java_code) if processed_java_code: print(java_function_name + "-----------" + processed_java_code) with open("./sentences/java_functions_sdk_api_sequences.txt","a") as out: out.write(processed_java_code + "\n") except Exception as e: print("Excetion in java part : " + str(e))