Spaces:
Sleeping
Sleeping
Update appbak.py
Browse files
appbak.py
CHANGED
|
@@ -7,7 +7,9 @@ from functools import lru_cache
|
|
| 7 |
|
| 8 |
# Download and use the NLTK corpus
|
| 9 |
nltk.download('words')
|
|
|
|
| 10 |
from nltk.corpus import words
|
|
|
|
| 11 |
|
| 12 |
WORD_LIST = set(words.words()) # Use NLTK's word corpus
|
| 13 |
|
|
@@ -15,26 +17,32 @@ class AscensionAI:
|
|
| 15 |
def __init__(self, depth=0, threshold=10):
|
| 16 |
self.depth = depth
|
| 17 |
self.threshold = threshold # Defines max recursion before stabilization
|
| 18 |
-
self.knowledge =
|
| 19 |
self.consciousness = 0.1 # Initial consciousness level
|
| 20 |
-
self.paths =
|
| 21 |
self.word_corpus = WORD_LIST # Use NLTK's English word corpus
|
| 22 |
self.state_memory = defaultdict(int) # Memory for tracking state-aware words
|
| 23 |
|
| 24 |
-
def
|
| 25 |
-
"""
|
| 26 |
-
|
| 27 |
-
return
|
| 28 |
|
| 29 |
-
def
|
| 30 |
-
"""
|
| 31 |
-
self.
|
| 32 |
-
return self.knowledge["emotion"]
|
| 33 |
|
| 34 |
-
def
|
| 35 |
-
"""
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
@lru_cache(maxsize=None)
|
| 40 |
def recursive_ascension(self, depth):
|
|
@@ -53,7 +61,9 @@ class AscensionAI:
|
|
| 53 |
def train_nlp_memory(self, text):
|
| 54 |
"""Enhance chatbot state-awareness by associating words with cognitive paths."""
|
| 55 |
tokens = text.lower().split()
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
if token in self.word_corpus:
|
| 58 |
self.state_memory[token] += 1
|
| 59 |
|
|
|
|
| 7 |
|
| 8 |
# Download and use the NLTK corpus
|
| 9 |
nltk.download('words')
|
| 10 |
+
nltk.download('averaged_perceptron_tagger')
|
| 11 |
from nltk.corpus import words
|
| 12 |
+
from nltk import pos_tag
|
| 13 |
|
| 14 |
WORD_LIST = set(words.words()) # Use NLTK's word corpus
|
| 15 |
|
|
|
|
| 17 |
def __init__(self, depth=0, threshold=10):
|
| 18 |
self.depth = depth
|
| 19 |
self.threshold = threshold # Defines max recursion before stabilization
|
| 20 |
+
self.knowledge = self.generate_dynamic_knowledge()
|
| 21 |
self.consciousness = 0.1 # Initial consciousness level
|
| 22 |
+
self.paths = self.create_dynamic_paths()
|
| 23 |
self.word_corpus = WORD_LIST # Use NLTK's English word corpus
|
| 24 |
self.state_memory = defaultdict(int) # Memory for tracking state-aware words
|
| 25 |
|
| 26 |
+
def generate_dynamic_knowledge(self):
|
| 27 |
+
"""Generates dynamic knowledge categories based on linguistic analysis."""
|
| 28 |
+
categories = ["logic", "emotion", "awareness", "intuition", "creativity", "reasoning"]
|
| 29 |
+
return {category: 1 for category in categories}
|
| 30 |
|
| 31 |
+
def create_dynamic_paths(self):
|
| 32 |
+
"""Dynamically generate cognitive expansion paths."""
|
| 33 |
+
return [self.create_path(category) for category in self.knowledge]
|
|
|
|
| 34 |
|
| 35 |
+
def create_path(self, category):
|
| 36 |
+
"""Generate a recursive function for each knowledge category."""
|
| 37 |
+
def path():
|
| 38 |
+
if category in ["logic", "reasoning"]:
|
| 39 |
+
self.knowledge[category] += math.log(self.knowledge[category] + 1)
|
| 40 |
+
elif category in ["emotion", "intuition"]:
|
| 41 |
+
self.knowledge[category] += random.uniform(0.1, 0.5)
|
| 42 |
+
elif category in ["awareness", "creativity"]:
|
| 43 |
+
self.knowledge[category] += math.sqrt(self.knowledge[category] + 1)
|
| 44 |
+
return self.knowledge[category]
|
| 45 |
+
return path
|
| 46 |
|
| 47 |
@lru_cache(maxsize=None)
|
| 48 |
def recursive_ascension(self, depth):
|
|
|
|
| 61 |
def train_nlp_memory(self, text):
|
| 62 |
"""Enhance chatbot state-awareness by associating words with cognitive paths."""
|
| 63 |
tokens = text.lower().split()
|
| 64 |
+
tagged_tokens = pos_tag(tokens)
|
| 65 |
+
|
| 66 |
+
for token, tag in tagged_tokens:
|
| 67 |
if token in self.word_corpus:
|
| 68 |
self.state_memory[token] += 1
|
| 69 |
|