This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let state = { | |
| foreground: '#999999', | |
| background: '#FFFFFF'; | |
| }; | |
| const imperativeMakeBackgroundBlack = () => { | |
| state.background = '#000000'; | |
| }; | |
| // directly changes the state object outside of its internal scope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>NLP in a browser</title> | |
| <script src='./dist/bundle.js'></script> | |
| <script> | |
| const {containerBootstrap, Nlp, LangEn, fs} = window.nlpjs; | |
| function onIntent(nlp, input) { | |
| console.log(input); | |
| if (input.intent === 'greetings.hello') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>NLP in a browser</title> | |
| <script src='./dist/bundle.js'></script> | |
| <script> | |
| const {containerBootstrap, Nlp, LangEn, fs} = window.nlpjs; | |
| const setupNLP = async corpus => { | |
| const container = containerBootstrap(); | |
| container.register('fs', fs); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "Corpus", | |
| "locale": "en-US", | |
| "data": [ | |
| { | |
| "intent": "agent.acquaintance", | |
| "utterances": [ | |
| "say about you", | |
| "why are you here", | |
| "what is your personality", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>NLP in a browser</title> | |
| <script src='./dist/bundle.js'></script> | |
| <script> | |
| const {containerBootstrap, Nlp, LangEn, fs} = window.nlpjs; | |
| const setupNLP = async corpus => { | |
| const container = containerBootstrap(); | |
| container.register('fs', fs); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "nlpjs-web", | |
| "version": "1.0.0", | |
| "scripts": { | |
| "build": "browserify ./buildable.js | terser --compress --mangle > ./dist/bundle.js", | |
| }, | |
| "devDependencies": { | |
| "@nlpjs/core": "^4.14.0", | |
| "@nlpjs/lang-en-min": "^4.14.0", | |
| "@nlpjs/nlp": "^4.15.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const core = require('@nlpjs/core'); | |
| const nlp = require('@nlpjs/nlp'); | |
| const langenmin = require('@nlpjs/lang-en-min'); | |
| const requestrn = require('@nlpjs/request-rn'); | |
| window.nlpjs = { ...core, ...nlp, ...langenmin, ...requestrn }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {upperCaseOf, trim, map, compose, Maybe} from '@7urtle/lambda'; | |
| const getElement = selector => Maybe.of(document.querySelector(selector)); | |
| const getText = element => element.textContent; | |
| const transformer = compose(trim, upperCaseOf); | |
| const getElementText = compose(map(transformer), map(getText), getElement); | |
| getElementText('#myTurtle'); // => Maybe('SHELLY') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| food(salad). % <- salad is food fact | |
| food(pizza). % <- pizza is food fact | |
| ?- food(salad). % <- is salad food? True | |
| ?- food(turtle). % <- is turtle food? False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const myComponent = props => ( | |
| <h1>Hello, {props.userName}</h1> | |
| }; |