Package org.apache.sysds.utils.stats

# Class NGramBuilder<T,U>

java.lang.Object
org.apache.sysds.utils.stats.NGramBuilder<T,U>

public class NGramBuilder<T,U> extends Object

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`NGramBuilder.NGramEntry<T,U>`

## Constructor Summary

Constructors
Constructor
Description
`NGramBuilder(Class<T> clazz, Class<U> clazz2, int size, Function<T,String> idGenerator, BiFunction<U,U,U> statsMerger)`

## Method Summary

Modifier and Type
Method
Description
`void`
`append(T element, U stat)`
`void`
`clearCurrentRecording()`
`int`
`getSize()`
`List<NGramBuilder.NGramEntry<T,U>>`
`getTopK(int k)`
`List<NGramBuilder.NGramEntry<T,U>>`
`getTopK(int k, Comparator<NGramBuilder.NGramEntry<T,U>> comparator, boolean reversed)`
`void`
`merge(NGramBuilder<T,U> builder)`
`static <T, U> String`
`toCSV(String[] columnNames, List<NGramBuilder.NGramEntry<T,U>> entries, Function<NGramBuilder.NGramEntry<T,U>,String> statsMapper)`
`static <T, U> void`
`toCSVStream(String[] columnNames, List<NGramBuilder.NGramEntry<T,U>> entries, Function<NGramBuilder.NGramEntry<T,U>,String> statsMapper, Consumer<String> lineConsumer)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### NGramBuilder

public NGramBuilder(Class<T> clazz, Class<U> clazz2, int size, Function<T,String> idGenerator, BiFunction<U,U,U> statsMerger)

## Method Details

### toCSV

public static <T, U> String toCSV(String[] columnNames, List<NGramBuilder.NGramEntry<T,U>> entries, Function<NGramBuilder.NGramEntry<T,U>,String> statsMapper)

### toCSVStream

public static <T, U> void toCSVStream(String[] columnNames, List<NGramBuilder.NGramEntry<T,U>> entries, Function<NGramBuilder.NGramEntry<T,U>,String> statsMapper, Consumer<String> lineConsumer)

### getSize

public int getSize()

### merge

public void merge(NGramBuilder<T,U> builder)

### append

public void append(T element, U stat)

### getTopK

public List<NGramBuilder.NGramEntry<T,U>> getTopK(int k)

### getTopK

public List<NGramBuilder.NGramEntry<T,U>> getTopK(int k, Comparator<NGramBuilder.NGramEntry<T,U>> comparator, boolean reversed)

### clearCurrentRecording

public void clearCurrentRecording()