Published
Edited
Apr 10, 2021
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
md `
***

![NLPTREE](https://media.giphy.com/media/hB7rlsDMpJdvTifVjZ/giphy.gif)

***

`
Insert cell
Insert cell
import { Button } from "@observablehq/inputs"
Insert cell
inputText = 'The the first thing you should do when you enter the the endless mania of the cosmic maze is to remember that your first impulse should be restraint. >The first thing I will do when I enter the endless mania of the cosmic maze is remember that my first impulse will be restraint >Frantically searching for the exit in a panic will only lead to exhaustion, entrapment. Indeed, many will not be able to resist the logic of the maze and submit to their confusion and fatigue and give up. However, for those whose restraint allows them to yield to oblivion, they will be rewarded. The sacred digital artifacts from The Holy State of Devendra are only accessible to those who do the work. This custom web application demands the user to become an active participant in the process of discovery-- only the devoted will arrive at the sacred digital artifacts. The cosmic website is made of forked notebooks, tied together with invisible strings. Each page contains a puzzle which leads to a secret link or password that opens the next web page or video. This project strives to interrupt the idea that a website should have a utilitarian function or serve the reader. This project seeks to remind the reader that the nightmare may be the path to utopia.>This work is inspired by the mythical invisible Bribrí gold, mazes, religious fantatics, mania, dark Iranian philosphers like Reza Negarestani and Jason Bahbak Mohaghegh, who use horror for their speculative fictions instead of science fiction.'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {signOff} from '@asg017/toolbox'
Insert cell
Terminal = (commands, options={}) => {
let {
w=width,
terminalStyle='',
commandPrefix='$ ',
shellPrefix=' > ',
outputPrefix='',
commandStyle='$ ',
shellStyle=' > ',
outputStyle='',
commandPrefixStyle='',
shellPrefixStyle='',
outputPrefixStyle='',
} = options;
console.log(commands)
if(Array.isArray(commands)) {
commands = commands.map(c=>{
if(typeof(c) === 'string')
return c.split('\n')
return c
}).flat()
}
else {
commands = commands.split('\n')
}


let randId = `terminal-id-${Math.floor(Math.random()*100)}-${Date.now()}`;
return html`
<style>

/* Add CSS here for ::before in prefix styling */
${commands.map( (c,i) => {
if (!c.prefix) return '';
return `#${randId}-${i}::before {
content: '${c.prefix}'!important;
}`}).join('\n')}

${'#'+randId} .command::before {
content: '${commandPrefix}';
color: #f1ff00;
${commandPrefixStyle}
}
${'#'+randId} .command {
${commandStyle}
}
${'#'+randId} .output {
/*Make the output non-copy-pasteable*/
-webkit-user-select: none; /* Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+/Edge */
user-select: none; /* Standard */
${outputStyle}
}
${'#'+randId} .output::before {
content: '${outputPrefix}';
${outputPrefixStyle}
}
${'#'+randId} .shell {
${shellStyle}
}
${'#'+randId} .shell::before {
content: '${shellPrefix}';
${shellPrefixStyle}
}
${'#'+randId}.terminal{
font-family: Consolas, monaco, monospace;
background-color:#000;
color:#FFF;
border-radius:5px;
padding: 10px 15px;
width: ${w};
margin: 0 auto;
${terminalStyle}
}
</style>
<div id="${randId}" class=terminal>
<div data-clipboard-target="copy-command">
${commands.map( (c,i) => {
let type = 'command';
let line = c.line || c;
let style = c.style || '';
if(c.type) // if command obj was passed
type = c.type;
else {
let res = /!(command|output|shell).*$/g.exec(line)
if (res) { // used something like '!command cat example.txt'
type = res[1]
line = line.slice( type.length+1)
}
}
return `<span id="${randId}-${i}" class=${type} style="${style}">${line}</span><br/>`;
})}
</div>
</div>`
}
Insert cell
button = (settings = {}) => {
if (typeof settings == 'string') return input({value: settings}, 'button');
else return input(settings, 'button');
}
Insert cell
md`---
### Imports`
Insert cell
import {
all_tokens,
sentence_sentiment,
people,
places,
positive_negative_verbs
} with { inputText as Alice_book } from "@amal994/visualizing-unstructured-text"
Insert cell
import { table } from "@tmcw/tables"
Insert cell
import { chart as wordCloudChart } with {
inputText as source
} from "@d3/word-cloud"
Insert cell
d3 = require('d3@5')
Insert cell
html2canvas = require('https://bundle.run/html2canvas@1.0.0-alpha.12')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more