Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
(def nlp
(let [props (new java.util.Properties)]
(.setProperty props "annotators" "tokenize,ssplit,parse,sentiment")
(new edu.stanford.nlp.pipeline.StanfordCoreNLP props)))
(defn find-sentiment
"Determines the sentiment of each sentence in a given glob of text. Results in a collection of integers ranging from [0-4]: where 0 is 'Very negative', 2 is 'neutral', and 4 is 'Very positive'"
[blob]
(let [glob (apply str blob)]
(let [main-sentiment 0
@petro-rudenko
petro-rudenko / DataworkerView.java
Last active January 2, 2016 00:19
Sample Ambari Interface
//Interface we need to implement
public interface DataworkerView {
public User getUser();
//E.g. String fs = getConfigValue("dataworker.defaultFs")
// fs -> "webhdfs://example.com:14000/"
public String getConfigValue(String configName);
  1. General Background and Overview
(use 'clojure.core.async)
;this is the function you want to use
(defn lazy-channels [chs]
(lazy-seq (cons (let [ [v _] (alts!! chs)] v) (lazy-channels chs))))
;now for the tesging
(def chs [ (chan) (chan) (chan) ]) ; the channels can come from anywhere, here we are using three channels for testing
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix.
;;
;; * :use makes functions available without a namespace prefix
;; (i.e., refers functions to the current namespace).
;;
;; * :import refers Java classes to the current namespace.
;;
(defn buffered-select [f-select init-pos]
"Creates a lazy sequence of messages for this datasource"
(letfn [
(m-seq [buff pos]
(let [buff2 (if (empty? buff) (f-select pos) buff)]
(cons (first buff2) (lazy-seq (m-seq (rest buff2) (inc pos) )))
)
)
]
(ns proc
(:import [java.lang ProcessBuilder])
(:use [clojure.java.io :only [reader writer]]))
(defn spawn [& args]
(let [process (-> (ProcessBuilder. args)
(.start))]
{:out (-> process
(.getInputStream)
(reader))

Tutorials