Loading notebooks/extract_kb_part.ipynb 0 → 100644 +37 −0 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python import json def extract_domain_knowledges(input_file, output_file, number_of_entries): # Read the original JSON file with open(input_file, 'r') as file: data = json.load(file) # Extract the first 'number_of_entries' domain knowledges extracted_data = data[:number_of_entries] # Write the extracted data to a new JSON file with open(output_file, 'w') as file: json.dump(extracted_data, file, indent=4) print(f"{number_of_entries} domain knowledges have been saved to {output_file}") ``` %% Cell type:code id: tags: ``` python # number of domain knowledges to extract number_to_extract = 50 # input and output file names input_filename = '../data/own_data/dialogue_domain_knowledge.json' # Replace with your actual input file name output_filename = 'extracted_domain_knowledges.json' # Run the function extract_domain_knowledges(input_filename, output_filename, number_to_extract) ``` %% Output 50 domain knowledges have been saved to extracted_domain_knowledges.json Loading
notebooks/extract_kb_part.ipynb 0 → 100644 +37 −0 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python import json def extract_domain_knowledges(input_file, output_file, number_of_entries): # Read the original JSON file with open(input_file, 'r') as file: data = json.load(file) # Extract the first 'number_of_entries' domain knowledges extracted_data = data[:number_of_entries] # Write the extracted data to a new JSON file with open(output_file, 'w') as file: json.dump(extracted_data, file, indent=4) print(f"{number_of_entries} domain knowledges have been saved to {output_file}") ``` %% Cell type:code id: tags: ``` python # number of domain knowledges to extract number_to_extract = 50 # input and output file names input_filename = '../data/own_data/dialogue_domain_knowledge.json' # Replace with your actual input file name output_filename = 'extracted_domain_knowledges.json' # Run the function extract_domain_knowledges(input_filename, output_filename, number_to_extract) ``` %% Output 50 domain knowledges have been saved to extracted_domain_knowledges.json