add sub cluster
This commit is contained in:
parent
104aef2eef
commit
fdcaff9982
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.log
|
||||||
@ -20,36 +20,6 @@ class PostSubClusterLLM:
|
|||||||
- if you found a good fit use its id : {{"cluster" : "id_i"}}
|
- if you found a good fit use its id : {{"cluster" : "id_i"}}
|
||||||
- if the title is not related to any of the cluster names, return "outlier" is "yes" : {{"outlier" : "yes"}}
|
- if the title is not related to any of the cluster names, return "outlier" is "yes" : {{"outlier" : "yes"}}
|
||||||
|
|
||||||
Example-1:
|
|
||||||
- Input:
|
|
||||||
- title: "کتاب و درس"
|
|
||||||
- all_cluster_names: {{
|
|
||||||
"1" : "کتابخوانی",
|
|
||||||
"2" : "فوتبال جام جهانی",
|
|
||||||
"3" : "ساختمان سازی شهری" }}
|
|
||||||
- Output:
|
|
||||||
- {{"cluster" : "1"}}
|
|
||||||
|
|
||||||
Example-2:
|
|
||||||
- Input:
|
|
||||||
- title: "لپتاب و کامپیوتر"
|
|
||||||
- all_cluster_names: {{
|
|
||||||
"1" : "کتابخوانی",
|
|
||||||
"2" : "فوتبال جام جهانی",
|
|
||||||
"3" : "ساختمان سازی شهری" }}
|
|
||||||
- Output:
|
|
||||||
- {{"outlier" : "yes"}}
|
|
||||||
|
|
||||||
Example-3:
|
|
||||||
- Input:
|
|
||||||
- title: "ساختمان"
|
|
||||||
- all_cluster_names: {{
|
|
||||||
"1" : "کتابخوانی",
|
|
||||||
"2" : "فوتبال جام جهانی",
|
|
||||||
"3" : "ساختمان سازی شهری" }}
|
|
||||||
- Output:
|
|
||||||
- {{"cluster" : "3"}}
|
|
||||||
|
|
||||||
write a small reason and give the final answer.
|
write a small reason and give the final answer.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -69,11 +39,16 @@ class PostSubClusterLLM:
|
|||||||
|
|
||||||
headers = {"Content-Type": "application/json",}
|
headers = {"Content-Type": "application/json",}
|
||||||
|
|
||||||
|
found_cluster = False
|
||||||
for cluster_sub_cluster in cluster_sub_cluster_list:
|
for cluster_sub_cluster in cluster_sub_cluster_list:
|
||||||
if cluster_sub_cluster["cluster_name"] == cluster_name:
|
if cluster_sub_cluster["cluster_name"] == cluster_name:
|
||||||
sub_cluster_names = cluster_sub_cluster["sub_cluster_names"]
|
sub_cluster_names = cluster_sub_cluster["sub_cluster_names"]
|
||||||
|
found_cluster = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if not found_cluster:
|
||||||
|
return None
|
||||||
|
|
||||||
sub_cluster_names_str = "{\n"
|
sub_cluster_names_str = "{\n"
|
||||||
for count, value in enumerate(sub_cluster_names):
|
for count, value in enumerate(sub_cluster_names):
|
||||||
sub_cluster_names_str += f"{count} : {value},\n"
|
sub_cluster_names_str += f"{count} : {value},\n"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user