Code Monkey home page Code Monkey logo

smart-lan's Introduction

#Smart Lan —— IOT WITH NLP

##Basic Example

  var _lexer, _trie, dict;

  var clock = 0;
  var deviceId = 0;
  var open = false;

  _lexer = new Geng.lexer();
  _trie = new Geng.trie();

  dict = ['晚上', '八点', '打开', '开启', '电暖'];
  _trie.init(dict);

  document.getElementById('dict').innerText = dict.toString();

  _lexer.addRule(/晚上/, function () {
    clock = clock + 12;
  });

  _lexer.addRule(/八点/, function () {
    clock = clock + 8;
  });

  _lexer.addRule(/开启|打开/, function () {
    open = true;
  });

  _lexer.addRule(/电暖气|电暖|暖气/, function (lexeme) {
    deviceId = 1;
  });

  var test_words = '晚上八点打开电暖气';
  var words = _trie.splitWords(test_words);

  function devices(number) {
    console.log(number);
  }

  devices.prototype.openAt = function (clock) {
      console.log(clock);
  };

  words.forEach(function (word) {
    _lexer.setInput(word);
    _lexer.lex();
  });

  if (open) {
    var device = new devices(deviceId);
    device.openAt(clock);
  }

smart-lan's People

Contributors

phodal avatar

Stargazers

Angus H. avatar

Watchers

 avatar  avatar

Forkers

muskanmahajan37

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.