-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategorisation.py
More file actions
44 lines (40 loc) · 1.29 KB
/
Copy pathcategorisation.py
File metadata and controls
44 lines (40 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'''
DESCRIPTION
Using the promptpatterns.json file, categorise the patterns into categories, subcategories and patterns.
NOTES
Version: 0.1
Author: Tim Haintz
Creation Date: 29/9/2023
LINKS:
https://resources.github.com/copilot-for-business/
HELP:
1. To generate a dot file for each title, run the following command:
```
python categorisation.py promptpatterns.json
```
This will generate a dot file for each title in the `graphvizFiles` folder.
2.
```
python categorisation.py promptpatterns.json ...........
```
'''
import os
import datetime
import json
def print_patterns_by_category(category):
# Load the JSON data from the file
with open('promptpatterns.json', 'r', encoding='utf-8') as f:
data = json.load(f)
# Get the patterns for the specified category
patterns = []
for title in data['Source']['Titles']:
for cat in title['CategoriesAndPatterns']:
if cat['PatternCategory'] == category:
patterns += [pattern['PatternName'] for pattern in cat['PromptPatterns']]
# Print the patterns for the specified category
if patterns:
print(f"Patterns for {category}:")
for pattern in patterns:
print(f"- {pattern}")
else:
print(f"No patterns found for {category}")