Eren5717 commited on
Commit
5b556c6
·
verified ·
1 Parent(s): 308a381

Upload 5 files

Browse files
data/code.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+
4
+ # Specify the path to your JSON file
5
+ file_path = 'github_dataset.json'
6
+
7
+ def update_custom_key_in_json(file_path):
8
+ try:
9
+ # Open the JSON file and load the data
10
+ with open(file_path, 'r') as file:
11
+ data = json.load(file)
12
+
13
+ # Check if the data is a list of dictionaries
14
+ if isinstance(data, list):
15
+ for item in data:
16
+ if isinstance(item, dict) and 'output' in item:
17
+ # Get the 'output' value and split it into words
18
+ output_text = item['output']
19
+ item['instruction'] = 'you are the github assistant'
20
+
21
+ words = output_text.split()
22
+
23
+ # Truncate the words to 2048 words if needed
24
+ if len(words) > 2048:
25
+ item['output'] = ' '.join(words[:2048])
26
+
27
+ # Save the updated data back to the JSON file
28
+ with open(file_path, 'w') as file:
29
+ json.dump(data, file, indent=4)
30
+
31
+ print("Output truncated to 2048 words successfully!")
32
+ else:
33
+ print("The JSON file doesn't contain a list of dictionaries.")
34
+
35
+ except Exception as e:
36
+ print(f"An error occurred: {e}")
37
+
38
+ # Call the function to update the custom key
39
+ update_custom_key_in_json(file_path)
data/github_dataset.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:982ff1c76e6b20c00f4cdb0778fb82f02bd59532d7c162c749fcb21c3093f798
3
- size 19250359
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab51df60435f5ee11469e1670a930aefffbd85dbe82325b7efd51254aab2f73e
3
+ size 18242778
data/stackoverflow_dataset.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b2cddd71c60351ff6587ae0008b7581828c201a9d79c4d6505919249dabed01e
3
- size 16969408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:608bb1fd4905b2f457e330d56ec4d6c728ce045c8a99ecc4aedd60a09bced28a
3
+ size 16939288
data/testing_github_dataset.json CHANGED
The diff for this file is too large to render. See raw diff
 
data/testing_stackoverflow_dataset.json CHANGED
The diff for this file is too large to render. See raw diff