Skip to main content

Posts

Showing posts from May, 2018

creating synonym mapping with wordnet dictionary

PUT /allvideos {   "settings": {     "analysis":{     "analyzer":{         "synonyms":{             "filter":[                 "lowercase",                 "synonym_filter"             ],         "tokenizer": "standard"     } }, "filter": {  "synonym_filter": {  "type": "synonym",  "format" : "wordnet",  "synonyms_path" : "analysis/wn_s.pl"  }  }   } } }

put mapping in elastic search using python

Code for creating and mapping a index with stemming {   "settings": {     "analysis": {       "analyzer": {         "english_exact": {           "tokenizer": "standard",           "filter": [             "lowercase"           ]         }       }     }   },   "mappings": {     "_doc": {       "properties": {         "body": {           "type": "text",           "analyzer": "english",           "fields": {             "exact": {               "type": "text",               "analyzer": "english_exact"             }           }         }       }     }   } }

python suprocess

python will keep communicating the output import subprocess print '\nread:' proc = subprocess.Popen(['autosub', 'test.mkv'],                         stdout=subprocess.PIPE,                         ) stdout_value = proc.communicate()[0] print '\tstdout:', repr(stdout_value)

carousel code for google assistant

'use strict'; const express = require('express'); const bodyParser = require('body-parser'); const NodeCache = require("node-cache"); var HashMap = require('hashmap'); //var courses = require('./index'); var chromeCast = require('./test.js'); const opn = require('opn'); let ActionsSdkApp = require('actions-on-google').ActionsSdkApp; process.env.DEBUG = 'actions-on-google:*'; const App = require('actions-on-google').DialogflowApp; const {     WebhookClient,     Payload } = require('dialogflow-fulfillment'); var ytc = require('./testy2'); var search = require('./search'); const restService = express(); restService.use(bodyParser.json()); const {     BasicCard } = require('actions-on-google') //use v2 alpha const DialogflowApp = require('actions-on-google').DialogflowApp; // Google Assistant helper library const googleAssistantReq

Working code for google smart card response dialogflow

'use strict'; const express = require('express'); const bodyParser = require('body-parser'); const NodeCache = require("node-cache"); var HashMap = require('hashmap'); //var courses = require('./index'); var chromeCast = require('./test.js'); const opn = require('opn'); process.env.DEBUG = 'actions-on-google:*'; const App = require('actions-on-google').DialogflowApp; const {WebhookClient, Payload} = require('dialogflow-fulfillment'); var ytc = require('./testy2'); var search = require('./search'); const restService = express(); restService.use(bodyParser.json()); const {  BasicCard } = require('actions-on-google') //use v2 alpha const DialogflowApp = require('actions-on-google').DialogflowApp; // Google Assistant helper library const googleAssistantRequest = 'google'; // Constant to identify Google Assistant requests restService.po

dialogflow webhook node js both v1 and v2 combined

'use strict'; const functions = require('firebase-functions'); // Cloud Functions for Firebase library const DialogflowApp = require('actions-on-google').DialogflowApp; // Google Assistant helper library exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {   console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));   console.log('Dialogflow Request body: ' + JSON.stringify(request.body));   if (request.body.result) {     processV1Request(request, response);   } else if (request.body.queryResult) {     processV2Request(request, response);   } else {     console.log('Invalid Request');     return response.status(400).end('Invalid Webhook Request (expecting v1 or v2 webhook request)');   } }); /* * Function to handle v1 webhook requests from Dialogflow */ function processV1Request (request, response) {   let action = request.body.result.action; // http

Commands

ssh pi@raspberrypi.local To search string inside filles of a given folder grep -rl "string" /path To get size of all folders inside a folder ->  du -sh */ git swtch remote branch if its not getting downloaded https://stackoverflow.com/questions/2294313/how-to-download-a-branch-with-git git checkout -t origin/branch-name copy file to server using scp (if it has pem file) scp -i mykey.pem somefile.txt root@my.ec2.id.amazonaws.com:/ Kill a process on a port ubuntu down vote accepted You want to use backtick not regular tick: sudo kill `sudo lsof -t -i:9001` If that doesn't work you could also use  $()  for command interpolation: sudo kill $(sudo lsof -t -i:9001)

synonym search for elasticSearch

PUT /my_index3 {   "settings": {     "analysis":{     "analyzer":{         "synonyms":{             "filter":[                 "lowercase",                 "synonym_filter"             ],         "tokenizer": "standard"     } }, "filter": { "synonym_filter": { "type": "synonym", "synonyms": [ "United States,US,USA,USA=>usa", "Alabama,Al,Ala,Ala", "Alaska,Ak,Alas,Alas", "Arizona,Az,Ariz", "Arkansas,Ar,Ark", "California,Ca,Calif,Cal", "Colorado,Co,Colo,Col", "Connecticut,Ct,Conn", "Deleware,De,Del", "District of Columbia,Dc,Wash Dc,Washington Dc=>Dc", "Florida,Fl,Fla,Flor", "Georgia,Ga", "Hawaii,Hi", "Idaho,Id,Ida", "Illinois,Il,Ill,Ills", "

Python2 writing and reading list in a file

https://stackoverflow.com/questions/17225287/python-2-7-write-and-read-a-list-from-file To write: with open ( the_filename , 'wb' ) as f : pickle . dump ( my_list , f ) To read: with open ( the_filename , 'rb' ) as f : my_list = pickle . load ( f ) If you  do  need them to be human-readable, we need more information. If  my_list  is guaranteed to be a list of strings with no embedded newlines, just write them one per line: with open ( the_filename , 'w' ) as f : for s in my_list : f . write ( s + '\n' ) with open ( the_filename , 'r' ) as f : my_list = [ line . rstrip ( '\n' ) for line in f ]