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
| <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
| 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
| const expression = input => input.toLowerCase(); | |
| const expression2 = function(input) { | |
| return input.toLowerCase(); | |
| }; | |
| const statement = () => console.log('hello world'); | |
| const statement2 = function() { | |
| console.log('hello world'); | |
| }; |
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 React, { useContext } from 'react'; | |
| import { StoreContext } from '../store/StoreContext'; | |
| const MyComponent = () => { | |
| const { state, actions } = useContext(StoreContext); | |
| const myAction = () => actions.triggerAction('data'); | |
| return( | |
| <> | |
| Number of button clicks: {state.counter}. |
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 React, { useState, useEffect } from 'react'; | |
| import axios from 'axios'; | |
| const MyComponent = () => { | |
| const [numberOfUsers, setNumberOfUsers] = useState(0); | |
| useEffect(() => { | |
| axios.get('/users/count') | |
| .then(response => setNumberOfUsers(response.data.count)) | |
| .catch(error => console.log('that is an error my friends: ' + error)); | |
| }, []); |
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
| // /src/store/types.js | |
| const types = { | |
| REQUEST_RANDOM_QUOTE: 'REQUEST_RANDOM_QUOTE', | |
| RECEIVE_RANDOM_QUOTE: 'RECEIVE_RANDOM_QUOTE' | |
| }; | |
| export default types; |
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
| // /src/store/actions.js | |
| import types from "./types"; | |
| export const useActions = (state, dispatch) => ({ | |
| requestRandomQuote: payload => dispatch({type: types.REQUEST_RANDOM_QUOTE, payload: payload}) | |
| }); |
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
| // src/store/reducers.js | |
| import types from "./types"; | |
| const initialState = { | |
| quote: 'Creativity is intelligence having fun.', | |
| author: 'Albert Einstein' | |
| }; | |
| const reducer = (state = initialState, action) => { |