| |
|
|
| import re |
| from typing import Dict, List, Tuple, Union, Optional |
|
|
| def validate_hypothesis(hypothesis: str) -> Tuple[bool, List[str]]: |
| """Validate a scientific hypothesis for basic quality criteria. |
| |
| Args: |
| hypothesis: The hypothesis text to validate |
| |
| Returns: |
| A tuple containing (is_valid, list_of_issues) |
| """ |
| issues = [] |
| |
| |
| if len(hypothesis) < 10: |
| issues.append("Hypothesis is too short") |
| |
| |
| if len(hypothesis) > 1000: |
| issues.append("Hypothesis is too long (>1000 characters)") |
| |
| |
| if hypothesis.strip().endswith("?"): |
| issues.append("Hypothesis should be a statement, not a question") |
| |
| |
| testability_terms = ["increase", "decrease", "affect", "change", "cause", |
| "lead to", "result in", "correlate", "association", |
| "relationship"] |
| |
| has_testability_term = any(term in hypothesis.lower() for term in testability_terms) |
| if not has_testability_term: |
| issues.append("Hypothesis may not be testable - consider including terms that describe relationships, effects, or changes") |
| |
| |
| vague_terms = ["very", "extremely", "many", "most", "few", "several", "a lot", |
| "better", "worse", "good", "bad", "significant"] |
| |
| found_vague_terms = [term for term in vague_terms if f" {term} " in f" {hypothesis.lower()} "] |
| if found_vague_terms: |
| issues.append(f"Hypothesis contains vague terms: {', '.join(found_vague_terms)}") |
| |
| |
| if not re.search(r"\b(if|when|as|while)\b", hypothesis.lower()) and \ |
| not re.search(r"\b(causes|affects|influences|impacts|changes|increases|decreases)\b", hypothesis.lower()): |
| issues.append("Hypothesis may not clearly specify variables or relationships to test") |
| |
| |
| is_valid = len(issues) <= 1 |
| |
| return is_valid, issues |
|
|
| def validate_research_goal(goal: str) -> Tuple[bool, List[str]]: |
| """Validate a research goal for basic quality criteria. |
| |
| Args: |
| goal: The research goal text to validate |
| |
| Returns: |
| A tuple containing (is_valid, list_of_issues) |
| """ |
| issues = [] |
| |
| |
| if len(goal) < 10: |
| issues.append("Research goal is too short") |
| |
| |
| if len(goal) > 500: |
| issues.append("Research goal is too long (>500 characters)") |
| |
| |
| appropriate_starts = ["to ", "the goal is to ", "this research aims to ", |
| "we aim to ", "this study seeks to ", "the purpose is to "] |
| |
| has_appropriate_start = any(goal.lower().startswith(start) for start in appropriate_starts) |
| if not has_appropriate_start: |
| issues.append("Research goal should typically start with 'To...' or similar phrase") |
| |
| |
| research_verbs = ["investigate", "explore", "analyze", "determine", "identify", |
| "examine", "understand", "evaluate", "assess", "develop", |
| "discover", "explain", "test", "validate", "characterize"] |
| |
| has_research_verb = any(f" {verb} " in f" {goal.lower()} " for verb in research_verbs) |
| if not has_research_verb: |
| issues.append("Research goal should include specific research action verbs") |
| |
| |
| if goal.strip().endswith("?"): |
| issues.append("Research goal should be a statement, not a question") |
| |
| |
| is_valid = len(issues) <= 1 |
| |
| return is_valid, issues |
|
|