analyze_content
Preview concept activation by analyzing content against neural memory graphs without saving results. Identify which associative concepts would trigger based on configured thresholds.
Instructions
Analyze content against concept nodes without saving. Preview which concepts would activate.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Content to analyze | |
| threshold | No | Activation threshold 0-1 (default: configured threshold) |
Implementation Reference
- src/hebbian_mind/server.py:504-600 (handler)The 'analyze_content' method of the 'HebbianMindDatabase' class implements the core logic for analyzing content, identifying activated nodes based on keywords and phrases, applying optional PRECOG boosting, and returning a list of activations.
def analyze_content(self, content: str, threshold: Optional[float] = None) -> List[Dict]: """Analyze content and return activated nodes. Enhanced with PRECOG ConceptExtractor (optional): - Extracts concepts using PRECOG's vocabulary-aware extraction - Boosts node scores when PRECOG concepts match node keywords - Adds 'precog_concepts' field to activation results """ if threshold is None: threshold = Config.ACTIVATION_THRESHOLD nodes = self.get_all_nodes() activations = [] content_lower = content.lower() # PRECOG Integration: Extract concepts for boosting precog_concepts = [] precog_concepts_lower = set() if PRECOG_AVAILABLE: try: precog_concepts = extract_concepts(content, max_concepts=15) precog_concepts_lower = {c.lower().replace("_", " ") for c in precog_concepts} precog_concepts_lower.update({c.lower().replace("_", "") for c in precog_concepts}) except Exception as e: print(f"[HEBBIAN-MIND] PRECOG extraction error: {e}", file=sys.stderr) for node in nodes: raw_keywords = node.get("keywords", []) keywords = json.loads(raw_keywords) if isinstance(raw_keywords, str) else raw_keywords raw_phrases = node.get("prototype_phrases", []) prototype_phrases = ( json.loads(raw_phrases) if isinstance(raw_phrases, str) else raw_phrases ) score = 0.0 matched_keywords = [] precog_boosted = False # Check keywords for keyword in keywords: keyword_lower = keyword.lower() if keyword_lower in content_lower: if re.search(r"\b" + re.escape(keyword_lower) + r"\b", content_lower): score += 0.25 matched_keywords.append(keyword) else: score += 0.1 # PRECOG boost: If PRECOG extracted this concept, boost the score if precog_concepts_lower and keyword_lower in precog_concepts_lower: score += 0.15 # PRECOG concept match bonus precog_boosted = True if f"[precog]{keyword}" not in matched_keywords: matched_keywords.append(f"[precog]{keyword}") # Check prototype phrases (higher weight) for phrase in prototype_phrases: if phrase.lower() in content_lower: score += 0.35 matched_keywords.append(f"[phrase]{phrase}") # Additional PRECOG boost: Check if node name matches PRECOG concepts node_name_lower = node["name"].lower().replace(" ", "_") node_name_nospace = node_name_lower.replace("_", "") if precog_concepts_lower: if ( node_name_lower in precog_concepts_lower or node_name_nospace in precog_concepts_lower ): if not precog_boosted: score += 0.2 # Node name matched PRECOG concept matched_keywords.append(f"[precog-node]{node['name']}") precog_boosted = True score = min(score, 1.0) if score >= threshold: activations.append( { "node_id": node["id"], "node_name": node["node_id"], "name": node["name"], "category": node["category"], "score": score, "matched_keywords": matched_keywords, "precog_boosted": precog_boosted, } ) activations.sort(key=lambda x: x["score"], reverse=True) # Attach PRECOG concepts to result metadata (available via first activation or separately) if activations and precog_concepts: # Store precog_concepts in a way that can be retrieved activations[0]["precog_concepts"] = precog_concepts return activations - src/hebbian_mind/server.py:1290-1326 (registration)The 'analyze_content' tool is registered in the MCP server's 'call_tool' handler in 'src/hebbian_mind/server.py'. It validates input and calls the 'db.analyze_content' method.
elif name == "analyze_content": content = _validate_string(arguments.get("content", ""), "content") threshold = arguments.get("threshold") if threshold is not None: threshold = _validate_number(threshold, "threshold", 0.0, 1.0) activations = db.analyze_content(content, threshold) # Extract PRECOG concepts from first activation if present precog_concepts = activations[0].get("precog_concepts", []) if activations else [] return [ types.TextContent( type="text", text=json.dumps( { "success": True, "threshold": threshold if threshold else Config.ACTIVATION_THRESHOLD, "activated_count": len(activations), "precog_available": PRECOG_AVAILABLE, "precog_concepts": precog_concepts, "activations": [ { "node": a["node_name"], "name": a["name"], "category": a["category"], "score": round(a["score"], 3), "matched_keywords": a["matched_keywords"], "precog_boosted": a.get("precog_boosted", False), } for a in activations ], }, indent=2, ), ) ] - src/hebbian_mind/server.py:1051-1065 (schema)The schema definition for the 'analyze_content' tool within the MCP server's 'list_tools' declaration.
types.Tool( name="analyze_content", description="Analyze content against concept nodes without saving. Preview which concepts would activate.", inputSchema={ "type": "object", "properties": { "content": {"type": "string", "description": "Content to analyze"}, "threshold": { "type": "number", "description": "Activation threshold 0-1 (default: configured threshold)", }, }, "required": ["content"], }, ),