package rivet.extras.text;

import static java.util.Arrays.stream;

import rivet.core.arraylabels.*;

public final class UntrainedWords {
    private UntrainedWords(){}
    
    public static String[] tokenizeText (String text) {
        return text.split("\\s+");
    }
    
    public static RIV[] rivWords (String[] words, int size, int k) {
        RIV[] res = new RIV[words.length];
        for (int i = 0; i < words.length; i++) {
            RIV riv = Labels.generateLabel(size, k, words[i]);
            res[i] = riv;
        }
        return res;
    }
    
    public static RIV sumRIVs (RIV[] rivs) { return Labels.addLabels(rivs); }
    
    public static RIV rivettizeText (String text, int size, int k) {
        return sumRIVs(rivWords(tokenizeText(text), size, k));
    }
    
}

@@ -93,16 +93,95 @@
 abels.*;
+%0Aimport rivet.core.labels.ArrayRIV;%0Aimport rivet.core.labels.RandomIndexVector;
 %0A%0Apublic
@@ -366,16 +366,21 @@
  static 
+Array
 RIV%5B%5D ri
@@ -430,16 +430,21 @@
         
+Array
 RIV%5B%5D re
@@ -451,16 +451,21 @@
 s = new 
+Array
 RIV%5Bword
@@ -536,16 +536,21 @@
         
+Array
 RIV riv 
@@ -551,22 +551,24 @@
 V riv = 
-Labels
+ArrayRIV
 .generat
@@ -683,21 +683,36 @@
 tic 
+Array
 RIV sum
+Array
 RIVs (
+Array
 RIV%5B
@@ -725,38 +725,164 @@
 ) %7B 
-return Labels.addLabels(rivs);
+%0A        return stream(rivs)%0A                .reduce(%0A                        new ArrayRIV(rivs%5B0%5D.size()),%0A                        (i, r) -%3E i.add(r));%0A   
  %7D%0A 
@@ -903,16 +903,21 @@
  static 
+Array
 RIV rive
@@ -977,16 +977,21 @@
 turn sum
+Array
 RIVs(riv

update to use ArrayRIV instead of arraylabels.RIV