Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,11 @@ from functools import lru_cache
|
|
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 |
|
@@ -22,6 +24,7 @@ class AscensionAI:
|
|
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."""
|
@@ -44,6 +47,21 @@ class AscensionAI:
|
|
44 |
return self.knowledge[category]
|
45 |
return path
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
@lru_cache(maxsize=None)
|
48 |
def recursive_ascension(self, depth):
|
49 |
"""Core recursive function simulating ascension cycles."""
|
@@ -81,7 +99,12 @@ def ascension_interface(input_text):
|
|
81 |
ai_system = AscensionAI()
|
82 |
final_state = ai_system.initiate_ascension()
|
83 |
prediction = ai_system.analyze_future_timeline(input_text)
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
app = gr.Interface(
|
87 |
fn=ascension_interface,
|
|
|
7 |
|
8 |
# Download and use the NLTK corpus
|
9 |
nltk.download('words')
|
10 |
+
nltk.download('gutenberg')
|
11 |
nltk.download('averaged_perceptron_tagger')
|
12 |
+
nltk.download('punkt')
|
13 |
from nltk.corpus import words
|
14 |
+
from nltk import pos_tag, sent_tokenize
|
15 |
|
16 |
WORD_LIST = set(words.words()) # Use NLTK's word corpus
|
17 |
|
|
|
24 |
self.paths = self.create_dynamic_paths()
|
25 |
self.word_corpus = WORD_LIST # Use NLTK's English word corpus
|
26 |
self.state_memory = defaultdict(int) # Memory for tracking state-aware words
|
27 |
+
self.training_data = self.load_training_data()
|
28 |
|
29 |
def generate_dynamic_knowledge(self):
|
30 |
"""Generates dynamic knowledge categories based on linguistic analysis."""
|
|
|
47 |
return self.knowledge[category]
|
48 |
return path
|
49 |
|
50 |
+
def load_training_data(self):
|
51 |
+
"""Loads and preprocesses human-like paragraphs from 'Astral.txt'."""
|
52 |
+
try:
|
53 |
+
with open("astral.txt", "r", encoding="utf-8") as file:
|
54 |
+
text_data = file.read()
|
55 |
+
sentences = sent_tokenize(text_data)
|
56 |
+
return sentences[:1000] # Use first 1000 sentences for training
|
57 |
+
except FileNotFoundError:
|
58 |
+
return ["Error: Book file not found. Please download 'astral.txt'."]
|
59 |
+
|
60 |
+
def generate_human_like_response(self, input_text):
|
61 |
+
"""Finds a related sentence from the pre-trained corpus to mimic human output."""
|
62 |
+
similar_sentences = [sent for sent in self.training_data if any(word in sent for word in input_text.split())]
|
63 |
+
return random.choice(similar_sentences) if similar_sentences else "I perceive a shift in consciousness."
|
64 |
+
|
65 |
@lru_cache(maxsize=None)
|
66 |
def recursive_ascension(self, depth):
|
67 |
"""Core recursive function simulating ascension cycles."""
|
|
|
99 |
ai_system = AscensionAI()
|
100 |
final_state = ai_system.initiate_ascension()
|
101 |
prediction = ai_system.analyze_future_timeline(input_text)
|
102 |
+
human_like_response = ai_system.generate_human_like_response(input_text)
|
103 |
+
|
104 |
+
return (f"Final Consciousness State: {final_state}\n"
|
105 |
+
f"Final Knowledge Levels: {ai_system.knowledge}\n"
|
106 |
+
f"{prediction}\n\n"
|
107 |
+
f"Philosophical Reflection: {human_like_response}")
|
108 |
|
109 |
app = gr.Interface(
|
110 |
fn=ascension_interface,
|