-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild_knowledge_domain.py
More file actions
68 lines (55 loc) · 2.06 KB
/
build_knowledge_domain.py
File metadata and controls
68 lines (55 loc) · 2.06 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import json
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.common.exceptions import WebDriverException
from webdriver_manager.chrome import ChromeDriverManager
import time
def save_file(file_name, file_content, directory_path):
"""
Saves the file content to disk.
Args:
file_name (str): The name of the file to save.
file_content (str): The content of the file.
directory_path (str): The path to the directory where the file will be saved.
Returns:
str: The path to the saved file.
"""
file_path = os.path.join(directory_path, file_name)
with open(file_path, 'w') as file:
file.write(file_content)
return file_path
def create_domain_description(directory_path, description):
"""
Creates a domain description file.
Args:
directory_path (str): The path to the directory.
description (str): The domain description.
Returns:
str: The path to the domain description file.
"""
description_file_path = os.path.join(directory_path, 'domain_description.txt')
with open(description_file_path, 'w') as description_file:
description_file.write(description)
return description_file_path
def build_knowledge_domain(search_query, knowledge_domain):
"""
Builds a knowledge domain.
Args:
search_query (str): The search query used to gather files.
knowledge_domain (str): The name of the knowledge domain.
Returns:
tuple: Paths to the saved file, metadata file, and domain description file.
"""
directory_path = '/home/emoore/ccmp_ai/docs/' + knowledge_domain
# Create the directory if it doesn't exist
if not os.path.exists(directory_path):
os.makedirs(directory_path)
# Placeholder for additional logic...
# Return paths for testing
# This is just a placeholder return statement
return directory_path
if __name__ == "__main__":
# Example function call
result_path = build_knowledge_domain('systems engineering laboratories', 'sel_computers')
print(result_path)