Skip to content

Instantly share code, notes, and snippets.

{
"name": "Corpus",
"locale": "en-US",
"data": [
{
"intent": "agent.acquaintance",
"utterances": [
"say about you",
"why are you here",
"what is your personality",
<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);
<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') {
let state = {
foreground: '#999999',
background: '#FFFFFF';
};
const imperativeMakeBackgroundBlack = () => {
state.background = '#000000';
};
// directly changes the state object outside of its internal scope
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');
};
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}.
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));
}, []);
// /src/store/types.js
const types = {
REQUEST_RANDOM_QUOTE: 'REQUEST_RANDOM_QUOTE',
RECEIVE_RANDOM_QUOTE: 'RECEIVE_RANDOM_QUOTE'
};
export default types;
// /src/store/actions.js
import types from "./types";
export const useActions = (state, dispatch) => ({
requestRandomQuote: payload => dispatch({type: types.REQUEST_RANDOM_QUOTE, payload: payload})
});
// src/store/reducers.js
import types from "./types";
const initialState = {
quote: 'Creativity is intelligence having fun.',
author: 'Albert Einstein'
};
const reducer = (state = initialState, action) => {