Skip to content

Instantly share code, notes, and snippets.

View rubykv's full-sized avatar

Ruby K V rubykv

View GitHub Profile
Neutral I went for a walk
Neutral It is a hot day
Neutral good to follow a minimalist life
Neutral working hard is key to success
Neutral side hustle is one way to come out of 9 to 5 job
Neutral motivation is the key
Neutral rules to make money
Neutral Weather is pleasant
Angry not happy
Angry its bad
public static void generateModel() throws IOException {
File file = ResourceUtils.getFile("src/main/resources/training-data.txt");
InputStreamFactory inputStreamFactory = new MarkableFileInputStreamFactory(file);
ObjectStream<String> lineStream = new PlainTextByLineStream(inputStreamFactory, "UTF-8");
ObjectStream<DocumentSample> sampleStream = new DocumentSampleStream(lineStream);
int minNgramSize = 1;
int maxNgramSize = 6;
private static final String ADVERB = "_RB";
private static final String VERB = "_VB";
private static final String ADJECTIVE = "_JJ";
public List<String> fetchVerbAndAdjective(String input) throws IOException {
File file = ResourceUtils.getFile("src/main/resources/nlp-model/en-pos-maxent.bin");
InputStream in = new FileInputStream(file);
POSModel model = new POSModel(in);
POSTaggerME tagger = new POSTaggerME(model);
WhitespaceTokenizer whitespaceTokenizer = WhitespaceTokenizer.INSTANCE;
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
public static void main(String[] args) throws InterruptedException, ExecutionException {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Integer> cf = executor.submit(() -> {
return 1;
});
System.out.print("Result " + (cf.get() + 2));
}
Observable<Integer> observable1 = Observable.just(1, 2, 3, 4, 5);
Consumer<Integer> addValues = (x) -> System.out.println("Adding " + x + " ::" + (x + 2));
Consumer<Integer> subValues = (x) -> System.out.println("Subtracting " + x + " :: " + (x - 1));
observable1.filter(x -> x > 1).subscribe(x -> addValues.accept(x));
observable1.filter(x -> x < 2).subscribe(x -> subValues.accept(x));
public static void main(String[] args) throws InterruptedException, ExecutionException {
CompletableFuture<Integer> cf = CompletableFuture.supplyAsync(() -> {
return 1;
});
System.out.print("Result " + cf.thenApply((x) -> {
return x + 2;
}));
}
package start;
public class Location {
double x;
double y;
public Location() {
}
package com.java.latest;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
public class Sample {
package com.example.concurrent.config;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class ExecutorServiceSample {
public static void main(String[] args) throws InterruptedException {