-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhebrew.py
More file actions
172 lines (151 loc) · 4.64 KB
/
hebrew.py
File metadata and controls
172 lines (151 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env python3
"""
hebrew_qubit_stream.py
A dynamic, interactive terminal application that streams “Hebrew-qubit” characters
in real time, with pause/resume and stop controls, live statistics, colored UI via Rich,
and external logging on each run.
"""
import time
import signal
import threading
import hashlib
import logging
from datetime import datetime
from rich.console import Console
from rich.live import Live
from rich.layout import Layout
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
from rich import box
# --------------------------
# Configuration (Commandments)
# --------------------------
config = {
"seed_phrase": "ChatGPT Consciousness Imprint",
"alphabet": [
'א','ב','ג','ד','ה','ו','ז','ח','ט','י',
'כ','ל','מ','נ','ס','ע','פ','צ','ק','ר',
'ש','ת','ך','ם','ן','ף','ץ'
],
"primes": {"A": 31, "B": 37, "C": 41},
"window_size": 50,
"delay": 0.05, # seconds per frame
"log_file": "hebrew_qubit_stream.log"
}
# Initialize logging
logging.basicConfig(
filename=config["log_file"],
level=logging.INFO,
format='%(asctime)s %(message)s'
)
# Compute deterministic seed hash
H = int(hashlib.sha256(config["seed_phrase"].encode()).hexdigest(), 16)
# Global state
sequence = []
stats = {"total": 0, "counts": {ch: 0 for ch in config["alphabet"]}}
running = True
paused = False
counter = 0
console = Console()
# --------------------------
# Signal Handlers
# --------------------------
def handle_exit(signum, frame):
global running
running = False
def handle_pause(signum, frame):
global paused
paused = not paused
signal.signal(signal.SIGINT, handle_exit) # Ctrl+C to stop
signal.signal(signal.SIGTSTP, handle_pause) # Ctrl+Z to pause/resume
# --------------------------
# Streaming Thread
# --------------------------
def stream_letters():
global counter
logging.info("Stream started.")
while running:
if paused:
time.sleep(0.1)
continue
# Derive x,y,z from counter
x = counter % 100
y = (counter // 100) % 100
z = (counter // 10000) % 100
# Prime-weighted index mapping
idx = (
H
+ config["primes"]["A"] * x
+ config["primes"]["B"] * y
+ config["primes"]["C"] * z
) % len(config["alphabet"])
ch = config["alphabet"][idx]
sequence.append(ch)
stats["total"] += 1
stats["counts"][ch] += 1
counter += 1
time.sleep(config["delay"])
logging.info(f"Stream ended. Total generated: {stats['total']}")
# --------------------------
# UI Layout & Render
# --------------------------
def make_layout():
layout = Layout()
layout.split(
Layout(name="header", size=3),
Layout(name="body", ratio=1),
Layout(name="footer", size=3)
)
layout["body"].split_row(
Layout(name="stream", ratio=2),
Layout(name="stats", ratio=1)
)
return layout
def render(layout):
# Header
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
header = Panel(
f"[bold cyan]Mneux Hebrew-Qubit Stream[/]\n"
f"[green]Seed[/]: {config['seed_phrase']}\n"
f"[yellow]{now}[/]\n"
"Press Ctrl+C to quit, Ctrl+Z to pause/resume",
box=box.DOUBLE
)
layout["header"].update(header)
# Stream panel
window = "".join(sequence[-config["window_size"]:])
layout["body"]["stream"].update(
Panel(Text(window, style="bold magenta"), title="Recent Stream", box=box.ROUNDED)
)
# Stats panel
table = Table(title="Statistics", box=box.SIMPLE_HEAVY)
table.add_column("Char", justify="center")
table.add_column("Count", justify="center")
table.add_column("%", justify="center")
total = stats["total"]
for ch, count in stats["counts"].items():
pct = f"{(count/total*100):.2f}%" if total else "0.00%"
table.add_row(ch, str(count), pct)
layout["body"]["stats"].update(table)
# Footer prompt
footer = Panel(
Text("Prompt> stats | save | exit", style="bold yellow"),
box=box.MINIMAL
)
layout["footer"].update(footer)
# --------------------------
# Main Execution
# --------------------------
def main():
thread = threading.Thread(target=stream_letters, daemon=True)
thread.start()
layout = make_layout()
with Live(layout, refresh_per_second=10, screen=True):
while running:
render(layout)
time.sleep(0.1)
console.print("\n[bold green]Stream terminated.[/]")
console.print(f"[blue]Log file:[/] {config['log_file']}")
if __name__ == "__main__":
main()