#Semantic Search engine – NLP lab
###17/05/2016 Task
Use the above blog to scrap the following information and show in terminal (ubuntu) or in a file in windows.
#Semantic Search engine – NLP lab
###17/05/2016 Task
Use the above blog to scrap the following information and show in terminal (ubuntu) or in a file in windows.
def value(k, degree, coefficients): | |
ans = 0 | |
prev = 1 | |
for i in xrange(degree+1): | |
if i != 0: | |
prev = prev * k | |
ans += coefficients[i] * prev | |
return ans | |
degree = input() | |
coefficients = map(int,raw_input().split()) |
;Clojure is compiled language but has a eval function like lisp which allows to run compiler within execution | |
;Visit https://learnxinyminutes.com/docs/clojure/ for more gists | |
5 ; ⇒ 5 | |
"hi" ; ⇒ "hi" | |
[1 2 3] ; evaluates to the vector `[1 2 3]` | |
(+ 1 2) ; evaluates to the sum of 1 and 2 | |
(if true "yes" "no") ; evaluates to the string "yes" | |
(println "hello!") ; evaluates to nil (but also prints "hello!") |
import elasticsearch as es | |
db = es.Elasticsearch(['y-monitoring-vm2.dnspam'], port= 9200) | |
db.delete_by_query(index= 'lake_garda_hadoop-test', doc_type='stock_accuracy', body={}) |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
//passing functions as params and executing them when required | |
def if2[A](cond: Boolean, onTrue: () => A, onFalse: () => A): A ={ | |
if (cond) onTrue() else onFalse() | |
} | |
//=> using arrow syntax pass params as unevaluated but they will be | |
//evaluated once they are referenced no need to mention () to execute them | |
def if2[A](cond: Boolean, onTrue: => A, onFalse: => A): A ={ | |
if (cond) onTrue else onFalse | |
} |
val x = { println("x"); 15 } | |
//x | |
//x: Int = 15 | |
lazy val y = { println("y"); 13 } | |
//y: Int = <lazy> | |
x | |
//res2: Int = 15 | |
y | |
//y |
check host appsrv1 with address 127.0.0.1 | |
start program = "/sbin/start myapp" | |
stop program = "/sbin/stop myapp" | |
alert alerts@example.com on {timeout,connection} | |
if failed port 9009 protocol HTTP | |
request / | |
with timeout 3 seconds | |
then restart | |
if 10 restarts within 10 cycles then timeout | |
if 10 restarts within 10 cycles then exec "/usr/bin/monit start aws-dns-healthcheck" |
I hereby claim:
To claim this, I am signing this object:
import org.apache.spark.sql.functions.udf | |
import spark.sessionState.conf | |
conf.setConfString("spark.sql.pivotMaxValues", "" + Int.MaxValue) | |
val csv = spark.read.format("csv").option("header", true).load("/Users/tilak/Downloads/Pam/SalesAnalysis/data/store_sales_unified_2017.csv") | |
val uniqueKey: (String, String, String, String) => String = (x, y, z, v) => x + "_" + y + "_" + z + "_" + v | |
val someFn = udf(uniqueKey) | |
val newData = csv.withColumn("unique", someFn(csv.col("receipt_id"), csv.col("cash_register_id"), csv.col("sale_time"), csv.col("date"))) | |
val countArticles = newData.groupBy("unique", "article_id").count() | |
var articles = countArticles.select("article_id").distinct() | |
val articleIds = articles.collect.map(x => x(0)) |