Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -194,7 +194,7 @@ from collections import Counter
|
|
194 |
|
195 |
def extract_problem_domains(df,
|
196 |
text_column='Processed_ProblemDescription_forDomainExtraction',
|
197 |
-
cluster_range=(6,
|
198 |
top_words=7):
|
199 |
consoleMessage_and_Print("Extracting Problem Domains...")
|
200 |
|
@@ -276,7 +276,7 @@ def text_processing_for_location(text):
|
|
276 |
def extract_location_clusters(df,
|
277 |
text_column1='Processed_LocationText_forClustering', # Extracted through NLP
|
278 |
text_column2='Geographical_Location', # User Input
|
279 |
-
cluster_range=(
|
280 |
top_words=3):
|
281 |
# Combine the two text columns
|
282 |
text_column = "Combined_Location_Text"
|
@@ -397,7 +397,7 @@ def generate_project_proposal(prompt):
|
|
397 |
|
398 |
|
399 |
|
400 |
-
|
401 |
|
402 |
|
403 |
|
@@ -415,24 +415,29 @@ def create_project_proposals(budget_cluster_df, problem_cluster_df, location_clu
|
|
415 |
|
416 |
location = ", ".join([item.strip() for item in location_clusters[loc] if item]) # Clean and join
|
417 |
problem_domain = ", ".join([item.strip() for item in problem_clusters[prob] if item]) # Clean and join
|
418 |
-
|
|
|
419 |
|
420 |
|
421 |
print("location: ", location)
|
422 |
print("problem_domain: ", problem_domain)
|
423 |
-
print("problem_descriptions: ",
|
424 |
|
425 |
# Check if problem_descriptions is valid (not NaN and not an empty list)
|
426 |
-
if isinstance(
|
427 |
# print(f"\nGenerating proposal for location: {location}, problem domain: {problem_domain}")
|
428 |
consoleMessage_and_Print(f"Generating PP")
|
429 |
|
|
|
430 |
# Prepare the prompt
|
431 |
# problems_summary = "; \n".join(problem_descriptions) # Join all problem descriptions
|
432 |
-
problems_summary = "; \n".join(problem_descriptions[:3]) # Limit to first 3 for brevity
|
|
|
|
|
433 |
|
434 |
# prompt = f"Generate a solution oriented project proposal for the following:\n\nLocation: {location}\nProblem Domain: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
435 |
-
prompt = f"Generate a solution-oriented project proposal for the following public problem (only output the proposal):\n\n Geographical/Digital Location: {location}\nProblem Category: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
|
|
436 |
|
437 |
proposal = generate_project_proposal(prompt)
|
438 |
# Check if proposal is valid
|
|
|
194 |
|
195 |
def extract_problem_domains(df,
|
196 |
text_column='Processed_ProblemDescription_forDomainExtraction',
|
197 |
+
cluster_range=(6, 8),
|
198 |
top_words=7):
|
199 |
consoleMessage_and_Print("Extracting Problem Domains...")
|
200 |
|
|
|
276 |
def extract_location_clusters(df,
|
277 |
text_column1='Processed_LocationText_forClustering', # Extracted through NLP
|
278 |
text_column2='Geographical_Location', # User Input
|
279 |
+
cluster_range=(3, 5),
|
280 |
top_words=3):
|
281 |
# Combine the two text columns
|
282 |
text_column = "Combined_Location_Text"
|
|
|
397 |
|
398 |
|
399 |
|
400 |
+
import copy
|
401 |
|
402 |
|
403 |
|
|
|
415 |
|
416 |
location = ", ".join([item.strip() for item in location_clusters[loc] if item]) # Clean and join
|
417 |
problem_domain = ", ".join([item.strip() for item in problem_clusters[prob] if item]) # Clean and join
|
418 |
+
shuffled_descriptions = copy.deepcopy(problem_cluster_df.loc[loc, prob])
|
419 |
+
# Create a deep copy of the problem descriptions, shuffle it, and join the first 10
|
420 |
|
421 |
|
422 |
print("location: ", location)
|
423 |
print("problem_domain: ", problem_domain)
|
424 |
+
print("problem_descriptions: ", shuffled_descriptions)
|
425 |
|
426 |
# Check if problem_descriptions is valid (not NaN and not an empty list)
|
427 |
+
if isinstance(shuffled_descriptions, list) and shuffled_descriptions:
|
428 |
# print(f"\nGenerating proposal for location: {location}, problem domain: {problem_domain}")
|
429 |
consoleMessage_and_Print(f"Generating PP")
|
430 |
|
431 |
+
random.shuffle(shuffled_descriptions)
|
432 |
# Prepare the prompt
|
433 |
# problems_summary = "; \n".join(problem_descriptions) # Join all problem descriptions
|
434 |
+
# problems_summary = "; \n".join(problem_descriptions[:3]) # Limit to first 3 for brevity
|
435 |
+
problems_summary = "; \n".join(shuffled_descriptions[:3])
|
436 |
+
|
437 |
|
438 |
# prompt = f"Generate a solution oriented project proposal for the following:\n\nLocation: {location}\nProblem Domain: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
439 |
+
# prompt = f"Generate a solution-oriented project proposal for the following public problem (only output the proposal):\n\n Geographical/Digital Location: {location}\nProblem Category: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
440 |
+
prompt = f"Generate a single solution-oriented project proposal bespoke to the following Location~Domain cluster of public problems:\n\n Geographical/Digital Location: {location}\nProblem Domain: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal: <only output this proposal>"
|
441 |
|
442 |
proposal = generate_project_proposal(prompt)
|
443 |
# Check if proposal is valid
|