Required background knowledge: activation record, static scoping & dynamic scoping.
Below is not standard C code. (case1)
foo (double a, double b){ double square (double z) { return z * z; } return square (a) + square (b); } |
This is my note of using WS4J calculate word similarity in Java. Step 1: Download Jars Download the following two jars and add them to your project library path. jawjaw-1.0.2.jar – https://code.google.com/p/jawjaw/downloads/list ws4j-1.0.1.jar – https://code.google.com/p/ws4j/downloads/list Step 2: Play With the Demo Program Code: package NLP; import edu.cmu.lti.lexical_db.ILexicalDatabase; import edu.cmu.lti.lexical_db.NictWordNet; import edu.cmu.lti.ws4j.RelatednessCalculator; import edu.cmu.lti.ws4j.impl.HirstStOnge; import … Read more
Required background knowledge: activation record, static scoping & dynamic scoping.
Below is not standard C code. (case1)
foo (double a, double b){ double square (double z) { return z * z; } return square (a) + square (b); } |
If you want to declare an empty vector in R, you can do the following: vec
In R, we can easily write a date frame object to a csv file. By using the method write.csv, the csv file can be generated under the same directory of your R script. write.csv(dataFrame, file=”median.csv”)
Installing R on Mac is very easy. Just download the installation file here: http://cran.r-project.org/bin/macosx/. The bin files will be automatically added to the PATH.
Installing R on Windows is pretty straightforward. Just go to the page and download the installation file here. Remember you need to add the bin directory to your “Path” environment variable.
Sometimes, you may want to run R Script by using command line. In this way, you can write a bash script and schedule a task everyday. In addition you can also pass different arguments to the R program. Create a R script “GetARgument.R”: args
The R code below reads a file line by line. path <- "/path/to/the/file" print(path) conn <- file(path,open="r") lines <- readLines(conn) for (i in 1:length(lines)){ print(lines[i]) } close(conn)path <- "/path/to/the/file" print(path) conn <- file(path,open="r") lines <- readLines(conn) for (i in 1:length(lines)){ print(lines[i]) } close(conn)
Method 1 String[] arr = { "ab", "bcd", "cdef", "defgh", "efhik", "fghijk", "ghijkl" }; Stream<String> stream = Stream.of(arr);String[] arr = { "ab", "bcd", "cdef", "defgh", "efhik", "fghijk", "ghijkl" }; Stream<String> stream = Stream.of(arr); Method 2 String[] arr = { "ab", "bcd", "cdef", "defgh", "efhik", "fghijk", "ghijkl" }; Stream<String> stream = Stream.of(arr); ArrayList<String> list = … Read more
You may often need to concat or merge two streams. In the Stream class, there is a static method concat() that can be used for this purpose. Merge Two Streams String[] arr1 = { "a", "b", "c", "d" }; String[] arr2 = { "e", "f", "g" }; Stream<String> stream1 = Stream.of(arr1); Stream<String> stream2 = Stream.of(arr2); … Read more
Problem Given an integer array, find the second largest number in the array. Solution The optimal time is linear to the length of the array N. We can iterate over the array, whenever the largest elements get updated, its current value becomes the second largest. public static int getSecondLargest(int[] arr){ int first = Integer.MIN_VALUE; int … Read more
If you are running a blog and use Google Adsense to monetize your blog. You may know that there are many ways to improve the performance of Adsense. This article demonstrates how to make the blog font to be like Google Adsense font, so that the ads looks like a part of the content. I … Read more