JSFiddle - React, Tailwind, and code Playground
JavaScript
// Usage:
// SequenceDatabase trainingSet = new SequenceDatabase();
// trainingSet.loadFileSPMFFormat("training_sequences.txt", Integer.MAX_VALUE, 0, Integer.MAX_VALUE);
// CPTPredictor predictionModel = new CPTPredictor("CPT");
// predictionModel.Train(trainingSet.getSequences());
// Sequence thePrediction = predictionModel.Predict(sequence);
// function getMatchingSequences(targetArray, intersection) {
// var intersection = null;
// if (targetArray.length == 1) {
// interesection = InvertedIndex.get(targetArray[i].value);
// } else {
// for (int i = 0; i < targetArray.length; i++ ) {
// var bitset = InvertedIndex.get(targetArray[i].value);
// if (bitset != null) {
// if (intersection == null) {
// intersection = bitset.clone();
// } else {
// intersection.and(bitset);
// }
// }
// }
// }
// if (intersection == null || intersection.cardinality() == 0) {
// return new BitVector();
// }
// return intersection;
// }