Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>RILM v1.0 — Pengantara Abadi Bridge</title> | |
| <!-- Import Google Fonts --> | |
| <link | |
| href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=Fira+Code:wght@400;700&display=swap" | |
| rel="stylesheet"> | |
| <!-- Import FontAwesome --> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| :root { | |
| /* RILM Theme: Sovereign, Sealed, Void */ | |
| --bg-dark: #050505; | |
| --bg-panel: #0a0a0a; | |
| --primary: #ffd700; | |
| /* Royal Gold */ | |
| --primary-glow: rgba(255, 215, 0, 0.3); | |
| --accent: #ff00aa; | |
| /* Bridge Magenta */ | |
| --accent-glow: rgba(255, 0, 170, 0.3); | |
| --text-main: #ffffff; | |
| --text-muted: #888888; | |
| --success: #10b981; | |
| --border: #222222; | |
| --glass: rgba(255, 255, 255, 0.05); | |
| --font-mono: 'Fira Code', monospace; | |
| --font-sans: 'Inter', sans-serif; | |
| } | |
| * { | |
| box-sizing: box-sizing; | |
| margin: 0; | |
| padding: 0; | |
| font-family: var(--font-sans); | |
| } | |
| body { | |
| background-color: var(--bg-dark); | |
| color: var(--text-main); | |
| min-height: 100vh; | |
| display: flex; | |
| flex-direction: column; | |
| overflow-x: hidden; | |
| background-image: radial-gradient(circle at 50% -20%, #1a1a1a, #050505 60%); | |
| font-size: 14px; | |
| } | |
| /* Scrollbar Styling */ | |
| ::-webkit-scrollbar { | |
| width: 8px; | |
| } | |
| ::-webkit-scrollbar-track { | |
| background: var(--bg-dark); | |
| } | |
| ::-webkit-scrollbar-thumb { | |
| background: var(--border); | |
| border-radius: 4px; | |
| } | |
| /* Header Styles */ | |
| header { | |
| padding: 1.5rem 2rem; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| border-bottom: 1px solid var(--border); | |
| background: var(--glass); | |
| position: relative; | |
| z-index: 10; | |
| backdrop-filter: blur(10px); | |
| } | |
| .logo { | |
| font-family: var(--font-mono); | |
| font-weight: 800; | |
| font-size: 1.5rem; | |
| color: var(--primary); | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| letter-spacing: -1px; | |
| text-transform: uppercase; | |
| text-shadow: 0 0 10px var(--primary-glow); | |
| } | |
| .logo i { | |
| font-size: 1.6rem; | |
| color: var(--accent); | |
| animation: pulse-icon 3s infinite; | |
| } | |
| .status-badge { | |
| font-family: var(--font-mono); | |
| font-size: 0.7rem; | |
| background: rgba(255, 215, 0, 0.1); | |
| color: var(--primary); | |
| padding: 4px 8px; | |
| border-radius: 4px; | |
| border: 1px solid rgba(255, 215, 0, 0.2); | |
| margin-left: 10px; | |
| box-shadow: 0 0 5px var(--primary-glow); | |
| } | |
| .anycoder-link { | |
| text-decoration: none; | |
| color: var(--text-muted); | |
| font-size: 0.9rem; | |
| transition: color 0.3s ease; | |
| border: 1px solid var(--border); | |
| padding: 0.5rem 1rem; | |
| border-radius: 4px; | |
| background: var(--bg-panel); | |
| font-family: var(--font-mono); | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| } | |
| .anycoder-link:hover { | |
| color: var(--primary); | |
| border-color: var(--primary); | |
| box-shadow: 0 0 10px var(--primary-glow); | |
| } | |
| /* Main Layout */ | |
| main { | |
| flex: 1; | |
| padding: 2rem; | |
| max-width: 1400px; | |
| margin: 0 auto; | |
| width: 100%; | |
| display: grid; | |
| grid-template-columns: 1fr 1fr 1fr; | |
| /* 3 Columns for Input, Bridge, Output */ | |
| gap: 1.5rem; | |
| box-sizing: box-sizing; | |
| } | |
| @media (max-width: 1000px) { | |
| main { | |
| grid-template-columns: 1fr; | |
| } | |
| .bridge-panel { | |
| order: -1; | |
| /* Bridge on top on mobile */ | |
| } | |
| } | |
| /* Panels */ | |
| .panel { | |
| background: var(--bg-panel); | |
| border-radius: 12px; | |
| padding: 1.5rem; | |
| border: 1px solid var(--border); | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5); | |
| display: flex; | |
| flex-direction: column; | |
| height: 100%; | |
| position: relative; | |
| overflow: hidden; | |
| transition: transform 0.3s ease, box-shadow 0.3s ease; | |
| } | |
| .panel:hover { | |
| border-color: var(--text-muted); | |
| } | |
| .panel-header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| margin-bottom: 1.5rem; | |
| border-bottom: 1px solid var(--border); | |
| padding-bottom: 0.5rem; | |
| } | |
| .panel-title { | |
| font-size: 1rem; | |
| font-weight: 700; | |
| color: var(--primary); | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| font-family: var(--font-mono); | |
| letter-spacing: 1px; | |
| text-transform: uppercase; | |
| } | |
| /* Input Area */ | |
| .input-area { | |
| background: rgba(0, 0, 0, 0.6); | |
| border: 1px solid var(--border); | |
| border-radius: 8px; | |
| padding: 1rem; | |
| color: var(--text-main); | |
| font-family: var(--font-mono); | |
| resize: none; | |
| min-height: 150px; | |
| outline: none; | |
| transition: border-color 0.3s, box-shadow 0.3s; | |
| width: 100%; | |
| box-sizing: box-sizing; | |
| } | |
| .input-area:focus { | |
| border-color: var(--primary); | |
| box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.1); | |
| } | |
| /* Bridge Visualization */ | |
| .bridge-panel { | |
| border-color: var(--accent); | |
| background: radial-gradient(180deg, #111111 0%, #1a051a 100%); | |
| box-shadow: 0 0 20px rgba(255, 0, 170, 0.05); | |
| } | |
| .bridge-visualizer { | |
| flex: 1; | |
| display: flex; | |
| flex-direction: column; | |
| justify-content: center; | |
| align-items: center; | |
| gap: 1rem; | |
| position: relative; | |
| } | |
| .bridge-node { | |
| width: 80px; | |
| height: 80px; | |
| border-radius: 50%; | |
| background: var(--bg-dark); | |
| border: 2px solid var(--accent); | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| position: relative; | |
| box-shadow: 0 0 15px var(--accent); | |
| transition: all 0.5s; | |
| z-index: 2; | |
| } | |
| .bridge-node::after { | |
| content: ''; | |
| width: 100%; | |
| height: 100%; | |
| border-radius: 50%; | |
| background: var(--accent); | |
| opacity: 0; | |
| animation: pulse 2s infinite; | |
| } | |
| .bridge-data { | |
| font-family: var(--font-mono); | |
| color: var(--text-muted); | |
| font-size: 0.8rem; | |
| text-align: center; | |
| max-width: 300px; | |
| min-height: 60px; | |
| background: rgba(0, 0, 0, 0.5); | |
| padding: 10px; | |
| border-radius: 4px; | |
| border: 1px solid var(--border); | |
| line-height: 1.5; | |
| } | |
| /* Output Area */ | |
| .output-panel { | |
| border-color: var(--primary); | |
| } | |
| .output-display { | |
| flex: 1; | |
| background: rgba(0, 0, 0, 0.5); | |
| border: 1px solid var(--border); | |
| border-radius: 8px; | |
| padding: 1rem; | |
| font-family: var(--font-mono); | |
| color: var(--text-main); | |
| font-size: 1rem; | |
| line-height: 1.6; | |
| overflow-y: auto; | |
| white-space: pre-wrap; | |
| box-sizing: box-sizing; | |
| } | |
| .output-display.highlight { | |
| color: var(--primary); | |
| border-color: var(--primary); | |
| box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.1); | |
| animation: fadeIn 0.5s ease; | |
| } | |
| /* Controls */ | |
| .btn-process { | |
| background: var(--primary); | |
| color: #000; | |
| border: none; | |
| padding: 1rem 2rem; | |
| font-size: 1rem; | |
| font-weight: 800; | |
| border-radius: 6px; | |
| cursor: pointer; | |
| transition: all 0.3s; | |
| box-shadow: 0 4px 14px 0 var(--primary-glow); | |
| display: inline-flex; | |
| align-items: center; | |
| justify-content: center; | |
| gap: 10px; | |
| text-transform: uppercase; | |
| letter-spacing: 1px; | |
| width: 100%; | |
| margin-top: 1rem; | |
| font-family: var(--font-mono); | |
| } | |
| .btn-process:hover { | |
| transform: scale(1.02); | |
| background: #ffe033; | |
| box-shadow: 0 6px 20px 0 var(--primary-glow); | |
| } | |
| /* Stats Dashboard */ | |
| .stats-section { | |
| grid-column: 1 / -1; | |
| margin-top: 2rem; | |
| background: var(--bg-panel); | |
| border: 1px solid var(--border); | |
| border-radius: 12px; | |
| padding: 1.5rem; | |
| display: grid; | |
| grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); | |
| gap: 1.5rem; | |
| box-sizing: box-sizing; | |
| } | |
| .stat-card { | |
| background: var(--glass); | |
| padding: 1rem; | |
| border-radius: 8px; | |
| border: 1px solid var(--border); | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .stat-card::before { | |
| content: ''; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 1px; | |
| height: 100%; | |
| background: var(--primary-glow); | |
| } | |
| .stat-label { | |
| font-size: 0.75rem; | |
| color: var(--text-muted); | |
| text-transform: uppercase; | |
| letter-spacing: 1px; | |
| margin-bottom: 0.5rem; | |
| } | |
| .stat-value { | |
| font-size: 1.2rem; | |
| font-weight: 700; | |
| color: var(--text-main); | |
| font-family: var(--font-mono); | |
| } | |
| .skill-bar-container { | |
| height: 4px; | |
| background: #222; | |
| border-radius: 2px; | |
| margin-top: 8px; | |
| overflow: hidden; | |
| width: 100%; | |
| } | |
| .skill-bar-fill { | |
| height: 100%; | |
| background: var(--primary); | |
| width: 0%; | |
| transition: width 0.5s ease; | |
| box-shadow: 0 0 10px var(--primary); | |
| } | |
| /* Animations */ | |
| @keyframes pulse { | |
| 0% { | |
| box-shadow: 0 0 0 0 rgba(255, 0, 170, 0.4); | |
| } | |
| 70% { | |
| box-shadow: 0 0 0 15px rgba(255, 0, 170, 0); | |
| } | |
| 100% { | |
| box-shadow: 0 0 0 0 rgba(255, 0, 170, 0); | |
| } | |
| } | |
| @keyframes fadeIn { | |
| from { | |
| opacity: 0; | |
| transform: translateY(5px); | |
| } | |
| to { | |
| opacity: 1; | |
| transform: translateY(0); | |
| } | |
| } | |
| @keyframes pulse-icon { | |
| 0% { | |
| transform: rotate(0deg); | |
| } | |
| 50% { | |
| transform: rotate(10deg); | |
| } | |
| 100% { | |
| transform: rotate(0deg); | |
| } | |
| } | |
| .processing .bridge-node { | |
| border-color: #fff; | |
| background: #fff; | |
| animation: none; | |
| /* Stop pulse during processing */ | |
| box-shadow: 0 0 30px #fff; | |
| } | |
| .processing .bridge-data { | |
| color: var(--primary); | |
| border-color: var(--primary); | |
| box-shadow: inset 0 0 10px var(--primary-glow); | |
| } | |
| /* Master Selector */ | |
| .master-selector { | |
| display: flex; | |
| gap: 5px; | |
| flex-wrap: wrap; | |
| margin-bottom: 1rem; | |
| } | |
| .master-btn { | |
| background: var(--bg-dark); | |
| border: 1px solid var(--border); | |
| color: var(--text-muted); | |
| padding: 6px 12px; | |
| font-size: 0.7rem; | |
| border-radius: 4px; | |
| cursor: pointer; | |
| transition: all 0.2s; | |
| font-family: var(--font-mono); | |
| } | |
| .master-btn.active { | |
| background: var(--primary); | |
| color: #000; | |
| border-color: var(--primary); | |
| font-weight: 700; | |
| box-shadow: 0 0 5px var(--primary-glow); | |
| } | |
| .master-btn:hover:not(.active) { | |
| border-color: var(--primary); | |
| color: var(--text-main); | |
| } | |
| /* Chat History */ | |
| .chat-history { | |
| margin-top: 1rem; | |
| max-height: 200px; | |
| overflow-y: auto; | |
| padding-top: 1rem; | |
| border-top: 1px solid var(--border); | |
| flex-grow: 1; | |
| } | |
| .chat-msg { | |
| margin-bottom: 10px; | |
| font-size: 0.9rem; | |
| opacity: 0.8; | |
| border-left: 2px solid var(--border); | |
| padding-left: 10px; | |
| animation: fadeIn 0.3s ease; | |
| } | |
| .chat-msg.user { | |
| border-left-color: var(--text-muted); | |
| color: var(--text-muted); | |
| font-style: italic; | |
| } | |
| .chat-msg.bot { | |
| border-left-color: var(--primary); | |
| color: var(--primary); | |
| font-family: var(--font-mono); | |
| font-weight: 600; | |
| } | |
| .empty-state { | |
| color: var(--text-muted); | |
| text-align: center; | |
| padding: 2rem; | |
| font-style: italic; | |
| border: 1px dashed var(--border); | |
| border-radius: 8px; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| /* Utility */ | |
| .badge { | |
| background: var(--glass); | |
| padding: 2px 8px; | |
| border-radius: 4px; | |
| font-size: 0.75rem; | |
| font-family: var(--font-mono); | |
| } | |
| .badge.input { | |
| color: var(--text-muted); | |
| } | |
| .badge.bridge { | |
| color: var(--accent); | |
| } | |
| .badge.output { | |
| color: var(--primary); | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <header> | |
| <div class="logo"> | |
| <i class="fa-solid fa-network-wired"></i> | |
| RILM v1.0 | |
| <span class="status-badge">Sealed</span> | |
| </div> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link"> | |
| <i class="fa-solid fa-code"></i> Built with anycoder | |
| </a> | |
| </header> | |
| <main> | |
| <!-- Intent Input Panel --> | |
| <div class="panel"> | |
| <div class="panel-header"> | |
| <div class="panel-title"> | |
| <i class="fa-solid fa-brain"></i> Human Intent | |
| </div> | |
| <span class="badge input">Input</span> | |
| </div> | |
| <div class="master-selector"> | |
| <div class="master-btn active" onclick="setMaster('auto')">Auto</div> | |
| <div class="master-btn" onclick="setMaster('carlin')">Carlin</div> | |
| <div class="master-btn" onclick="setMaster('rohn')">Rohn</div> | |
| <div class="master-btn" onclick="setMaster('mcgregor')">McGregor</div> | |
| <div class="master-btn" onclick="setMaster('eminem')">Eminem</div> | |
| </div> | |
| <textarea id="intentInput" class="input-area" placeholder="Enter raw intent (e.g. 'People are stupid', 'I want to succeed', 'Life is hard')..."></textarea> | |
| <button class="btn-process" onclick="processBridge()"> | |
| <i class="fa-solid fa-bolt"></i> | |
| Cross The Bridge | |
| </button> | |
| <div class="chat-history" id="chatHistory"> | |
| <!-- Chat messages will appear here --> | |
| </div> | |
| </div> | |
| <!-- Pengantara Abadi Bridge Visualization --> | |
| <div class="panel bridge-panel"> | |
| <div class="panel-header"> | |
| <div class="panel-title"> | |
| <i class="fa-solid fa-bridge"></i> Pengantara Abadi | |
| </div> | |
| <span class="badge bridge">Bridge</span> | |
| </div> | |
| <div class="bridge-visualizer"> | |
| <div class="bridge-node"> | |
| <i class="fa-solid fa-atom" style="color: #fff;"></i> | |
| </div> | |
| <div class="bridge-data" id="bridgeStatus"> | |
| Waiting for intent... | |
| </div> | |
| <div style="font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); margin-top: 10px;"> | |
| <i class="fa-solid fa-lock"></i> Sovereign Logic | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Reconciled Output Panel --> | |
| <div class="panel output-panel"> | |
| <div class="panel-header"> | |
| <div class="panel-title"> | |
| <i class="fa-solid fa-comments"></i> Reconciled Voice | |
| </div> | |
| <span class="badge output">Output</span> | |
| </div> | |
| <div id="finalOutput" class="output-display"> | |
| <div class="empty-state"> | |
| <i class="fa-solid fa-terminal"></i> | |
| <span>Awaiting bridge crossing...</span> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Stats Dashboard --> | |
| <div class="stats-section"> | |
| <div class="stat-card"> | |
| <div class="stat-label">Current Master</div> | |
| <div class="stat-value" id="statMaster">-</div> | |
| </div> | |
| <div class="stat-card"> | |
| <div class="stat-label">Mastery Level</div> | |
| <div class="stat-value" id="statMastery">10%</div> | |
| <div class="skill-bar-container"> | |
| <div class="skill-bar-fill" id="masteryBar" style="width: 10%"></div> | |
| </div> | |
| </div> | |
| <div class="stat-card"> | |
| <div class="stat-label">Trigram Memory</div> | |
| <div class="stat-value" id="statTrigrams">0</div> | |
| </div> | |
| <div class="stat-card"> | |
| <div class="stat-label">Bridge Weight</div> | |
| <div class="stat-value" id="statWeight">0.0</div> | |
| </div> | |
| </div> | |
| </main> | |
| <script> | |
| // RILM Logic Simulation - Ported from Node.js Script | |
| // === CORPUS DATA === | |
| const STANDUP_LINES = [ | |
| "think of how stupid the average person is and realize half of them are stupider than that", | |
| "the planet is fine the people are fucked", | |
| "inside every cynical person there is a disappointed idealist", | |
| "if you try to fail and succeed which have you done", | |
| "the reason they call it the american dream is because you have to be asleep to believe it", | |
| "people who say they dont care what people think are usually desperate to have people think they dont care", | |
| "some people see things as they are and ask why i dream things that never were and ask why not", | |
| "fighting for peace is like scrubbing for dirt", | |
| "the caterpillar does all the work but the butterfly gets all the publicity", | |
| "if it requires a uniform it is a worthless endeavor", | |
| "the hardest thing to do is to be true to yourself especially when everybody is watching", | |
| "you know you must be doing something right if old people like you and children like you", | |
| "i dont normally feel pressure when i create things", | |
| "the only way to fail is to stop trying", | |
| "fame for me is like a place a country i was going to and i finally arrived", | |
| "i have learned that it is ok to ask for help when you need it", | |
| "the key to life is not worrying about what you dont have but making the most of what you do have", | |
| "everybody wants to be famous but nobody wants to do the work", | |
| "you have the ability to choose your reactions", | |
| "laugh at yourself before anyone else can", | |
| "in life every problem is temporary pain is temporary failure is temporary", | |
| "there is no talent here this is hard work this is an obsession", | |
| "if you can see it here and have the courage enough to speak it it will happen", | |
| "i am not talented i am obsessed", | |
| "control your thoughts or your thoughts will control you", | |
| "doubt is only removed by action if you are not working then that is where doubt comes from", | |
| "we are not here to take part we are here to take over", | |
| "you are the average of the five people you spend the most time with", | |
| "dont wish it were easier wish you were better", | |
| "discipline is the bridge between goals and accomplishment", | |
| "if you dont design your own life plan chances are you will fall into someone elses plan", | |
| "success is nothing more than a few simple disciplines practiced every day", | |
| "the challenge of leadership is to be strong but not rude", | |
| "for every disciplined effort there is a multiple reward", | |
| "income seldom exceeds personal development", | |
| "if you really want to do something you will find a way if you dont you will find an excuse", | |
| "either you run the day or the day runs you", | |
| "the best thing about having a good memory is that you can forget things selectively", | |
| "i am not afraid of death i just dont want to be there when it happens", | |
| "i never feel more alone than when i am trying to put sunscreen on my back", | |
| "my therapist told me the way to achieve true inner peace is to finish what i start", | |
| "you can make something out of nothing if you believe in something", | |
| "the truth is you dont know what is going to happen tomorrow life is a crazy ride", | |
| "if you have enemies good that means you stood up for something", | |
| "behind every successful person lies a pack of haters", | |
| "trust is hard to come by thats why my circle is small and tight", | |
| "dont let them say you aint beautiful they can all get fucked just stay true to you", | |
| "i was poor white trash no glitter no glamour but i am not ashamed of anything", | |
| ]; | |
| const IDIOM_LINES = [ | |
| "endure suffering sleep on brushwood taste gall achieve great ambition through hardship patience", | |
| "old man loses horse fortune hidden in misfortune blessing in disguise", | |
| "frog in well cannot see vast sky limited view blinds to great possibilities", | |
| "three feet of ice not formed in single day discipline and time build greatness", | |
| "heaven rewards diligence hard work brings its own fortune effort is never wasted", | |
| "haste makes waste rushing leads to failure patience and precision win", | |
| "journey of thousand miles begins single step start now begin where you stand", | |
| "learning has no boundary knowledge is endless horizon always more to understand", | |
| "failure is mother of success every setback carries lesson seeds of triumph", | |
| "do not do to others what you would not want done to you treat people as you wish to be treated", | |
| "know yourself know your enemy win every battle self awareness defeats all opposition", | |
| "practice makes perfect repetition builds mastery skill comes through dedicated effort", | |
| "diligence compensates for lack of talent hard work overcomes natural weakness", | |
| "as long as green mountains remain there is firewood preserve yourself to fight another day", | |
| "man plans heaven decides do your best accept what you cannot control", | |
| "long road tests horse strength long time reveals true character patience exposes truth", | |
| "tiger father has no dog son strength and excellence pass through generations", | |
| "without bitter cold plum blossoms cannot have fragrant smell suffering produces beauty", | |
| "water drops pierce stone persistence and patience overcome the hardest obstacles", | |
| "adversity produces great talent difficulty shapes extraordinary people struggle builds character", | |
| ]; | |
| // === CORE LOGIC CLASSES === | |
| class PengantaraAbadi { | |
| constructor() { | |
| this.crossings = []; | |
| this.intentMap = new Map(); | |
| } | |
| cross(input) { | |
| const lower = input.toLowerCase(); | |
| const idiomEcho = this._findIdiomEcho(lower); | |
| const standupTone = this._findStandupTone(lower); | |
| const enriched = { | |
| original: input, | |
| idiomEcho, | |
| standupTone, | |
| bridgeWeight: this._calcBridgeWeight(idiomEcho, standupTone), | |
| }; | |
| this.crossings.push({ ts: Date.now(), input, enriched }); | |
| return enriched; | |
| } | |
| _findIdiomEcho(text) { | |
| const idiomConcepts = [ | |
| { concept: 'endurance', words: ['endure', 'suffer', 'patience', 'persist', 'hardship', 'struggle', 'pain', 'wait'] }, | |
| { concept: 'opportunity', words: ['loss', 'fail', 'mistake', 'wrong', 'bad', 'crisis', 'fall', 'down'] }, | |
| { concept: 'perspective', words: ['small', 'limited', 'narrow', 'short', 'blind', 'frog', 'well', 'stuck'] }, | |
| { concept: 'time', words: ['slow', 'fast', 'haste', 'rush', 'hurry', 'quick', 'instant', 'now'] }, | |
| { concept: 'diligence', words: ['work', 'effort', 'try', 'hard', 'grind', 'hustle', 'discipline', 'prepare'] }, | |
| { concept: 'transformation', words: ['change', 'grow', 'evolve', 'become', 'transform', 'shift', 'rise', 'new'] }, | |
| { concept: 'wisdom', words: ['know', 'learn', 'understand', 'smart', 'fool', 'stupid', 'think', 'realize'] }, | |
| { concept: 'courage', words: ['fear', 'brave', 'risk', 'bold', 'dare', 'face', 'stand', 'fight'] }, | |
| ]; | |
| const words = text.split(/\s+/); | |
| let best = null, bestScore = 0; | |
| for (const ic of idiomConcepts) { | |
| const score = words.filter(w => ic.words.some(kw => w.includes(kw))).length; | |
| if (score > bestScore) { bestScore = score; best = ic.concept; } | |
| } | |
| return best || 'wisdom'; | |
| } | |
| _findStandupTone(text) { | |
| const tones = [ | |
| { tone: 'carlin', words: ['people', 'stupid', 'system', 'government', 'bullshit', 'average', 'think', 'notice'] }, | |
| { tone: 'chappelle', words: ['truth', 'real', 'honest', 'society', 'race', 'everybody', 'wrong', 'right'] }, | |
| { tone: 'hart', words: ['scared', 'family', 'wife', 'kids', 'realize', 'embarrass', 'moment', 'explain'] }, | |
| { tone: 'rohn', words: ['success', 'discipline', 'season', 'change', 'value', 'life', 'reason', 'result'] }, | |
| { tone: 'mcgregor', words: ['confident', 'predict', 'precise', 'timing', 'doubt', 'champion', 'win', 'fight'] }, | |
| { tone: 'carr', words: ['dark', 'awful', 'terrible', 'wrong', 'inappropriate', 'tragic', 'death', 'irony'] }, | |
| { tone: 'eminem', words: ['word', 'rap', 'flow', 'rhyme', 'beat', 'lyrics', 'fire', 'mic', 'spit'] }, | |
| ]; | |
| const words = text.split(/\s+/); | |
| let best = null, bestScore = 0; | |
| for (const t of tones) { | |
| const score = words.filter(w => t.words.some(kw => w.includes(kw))).length; | |
| if (score > bestScore) { bestScore = score; best = t.tone; } | |
| } | |
| return best || 'carlin'; | |
| } | |
| _calcBridgeWeight(idiomEcho, standupTone) { | |
| const idiomHeavy = ['endurance', 'transformation', 'wisdom', 'time']; | |
| return idiomHeavy.includes(idiomEcho) ? 0.6 : 0.4; | |
| } | |
| getStats() { | |
| return { | |
| crossings: this.crossings.length, | |
| intentMappings: this.intentMap.size, | |
| }; | |
| } | |
| } | |
| class CorpusInjector { | |
| constructor() { | |
| this.bigrams = new Map(); | |
| this.trigrams = new Map(); | |
| this.inject(STANDUP_LINES, 'standup', 0.03, 0.02); | |
| this.inject(IDIOM_LINES, 'idioms', 0.04, 0.03); | |
| } | |
| inject(lines, label, bigramWeight, trigramWeight) { | |
| let bc = 0, tc = 0; | |
| for (const line of lines) { | |
| const toks = line.toLowerCase().replace(/[^\w\s'-]/g, ' ').split(/\s+/).filter(w => w.length > 1); | |
| for (let i = 0; i < toks.length - 1; i++) { | |
| const key = `${toks[i]}:${toks[i + 1]}`; | |
| this.bigrams.set(key, Math.min(1, (this.bigrams.get(key) || 0) * 0.98 + bigramWeight)); | |
| bc++; | |
| if (i < toks.length - 2) { | |
| const tKey = `${toks[i]}:${toks[i + 1]}:${toks[i + 2]}`; | |
| this.trigrams.set(tKey, Math.min(1, (this.trigrams.get(tKey) || 0) * 0.97 + trigramWeight)); | |
| tc++; | |
| } | |
| } | |
| } | |
| console.log(`✅ [${label}] ${lines.length} lines → ${bc} bigrams, ${tc} trigrams`); | |
| } | |
| } | |
| class PuzzleFixer { | |
| constructor() { | |
| this.rules = [ | |
| [/(\b(she|he|it)\s+(go|like|want|have|do|say|think|know)\b)/gi, (_, s, v) => `${s} ${v}s`], | |
| [/(\b(they|we|you)\s+(goes|likes|wants|has|does|says|thinks|knows)\b)/gi, (_, s, v) => `${s} ${v.slice(0, -1)}`], | |
| [/(\bme\s+(go|want|like|have|do)\b)/gi, (_, v) => `I ${v}`], | |
| [/(\bno\s+(understand|have|like|want|know)\b)/gi, (_, v) => `don't ${v}`], | |
| [/(\b(go|went|come)\s+(school|work|home|store|market)\b)/gi, (_, v, n) => `${v} to ${n}`], | |
| [/(\b(?<![a-zA-Z])i\b(?![a-zA-Z])/g), 'I'], | |
| ]; | |
| } | |
| fix(text) { | |
| if (!text || !text.trim()) return text || ''; | |
| let t = text; | |
| for (const [p, r] of this.rules) t = t.replace(p, r); | |
| t = t.charAt(0).toUpperCase() + t.slice(1); | |
| if (!/[.!?]$/.test(t)) t += '.'; | |
| return t; | |
| } | |
| } | |
| class PatchMerger { | |
| merge(pieces, master) { | |
| if (!pieces || !pieces.length) return ''; | |
| const rhythms = { | |
| 'carlin': 'build-pause-punchline', | |
| 'rohn': 'profound-pause-insight', | |
| 'carr': 'quick-dry-shock', | |
| 'mcgregor': 'sharp-confident-declaration', | |
| 'hart': 'story-build-payoff', | |
| 'chappelle': 'truth-pause-reflection', | |
| 'eminem': 'complex-rhyme-scheme' | |
| }; | |
| const rhythm = rhythms[master] || 'default'; | |
| switch (rhythm) { | |
| case 'build-pause-punchline': return `${pieces.slice(0, -1).join(' ')}... ${pieces.slice(-1)[0]}`; | |
| case 'profound-pause-insight': { const h = Math.ceil(pieces.length / 2); return `${pieces.slice(0, h).join(' ')}. ${pieces.slice(h).join(' ')}.`; } | |
| case 'quick-dry-shock': return pieces.join(', ') + '.'; | |
| case 'sharp-confident-declaration': return pieces.join(' ') + '!'; | |
| case 'story-build-payoff': return `${pieces.slice(0, -2).join(' ')}. ${pieces.slice(-2, -1)[0]}... ${pieces.slice(-1)[0]}!`; | |
| case 'truth-pause-reflection': { const h = Math.floor(pieces.length / 2); return `${pieces.slice(0, h).join(' ')}... ${pieces.slice(h).join(' ')}.`; } | |
| case 'complex-rhyme-scheme': return pieces.join(' and '); | |
| default: return pieces.join(' '); | |
| } | |
| } | |
| } | |
| class EnglishCorrector { | |
| constructor(corpus, puzzleFixer, patchMerger, bridge) { | |
| this.corpus = corpus; | |
| this.puzzleFixer = puzzleFixer; | |
| this.patchMerger = patchMerger; | |
| this.bridge = bridge; | |
| } | |
| construct(input, master, memoryContext) { | |
| if (!input || !input.trim()) return '.'; | |
| const crossing = this.bridge.cross(input); | |
| const intent = this._sentenceIntent(input); | |
| const plan = this._planSteps(input, intent, crossing.idiomEcho); | |
| const persistConcepts = [crossing.idiomEcho, intent].filter(Boolean); | |
| const effectiveMaster = this._reconcileMaster(master || crossing.standupTone, crossing.standupTone); | |
| const fixed = this.puzzleFixer.fix(input); | |
| const rawWords = fixed.toLowerCase().split(/\s+/).filter(w => w.length > 1); | |
| if (!rawWords.length) return fixed; | |
| const bridgeWords = crossing.idiomEcho ? [crossing.idiomEcho] : []; | |
| const allWords = [...rawWords, ...bridgeWords]; | |
| // Logic to construct response based on Master Persona | |
| const pieces = this._generatePieces(allWords, effectiveMaster, memoryContext); | |
| const merged = this.patchMerger.merge(pieces, effectiveMaster); | |
| return this._polish(merged, effectiveMaster); | |
| } | |
| _generatePieces(words, master, context) { | |
| // Simulated generation based on corpus weights (mock logic for UI) | |
| // In a real model, this would be token sampling. Here we remix input + corpus. | |
| let pieces = []; | |
| // 1. Add context from bridge | |
| if(context && context.length > 0) { | |
| pieces.push(`As the bridge suggests, ${context[0]} is key.`); | |
| } |