<commit_before>package org.numenta.nupic.examples.cortical_io.breakingnews;

import gnu.trove.list.array.TIntArrayList;
import io.cortical.rest.model.Fingerprint;
import io.cortical.rest.model.Metric;
import io.cortical.services.RetinaApis;
import io.cortical.services.api.client.ApiException;
import io.cortical.twitter.Algorithm;
import io.cortical.twitter.Tweet;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Semaphore;

import org.numenta.nupic.network.Inference;
import org.numenta.nupic.network.Network;
import org.numenta.nupic.util.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import rx.Subscriber;

import com.fasterxml.jackson.core.JsonProcessingException;

/**
 * An implementation of {@link Algorithm} that closely follows the original
 * logic used for the hackathon hack (as opposed to other experimental variations
 * this author may propose).
 * 
 * @author cogmission
 * @see Algorithm
 */
public class StrictHackathonAlgorithm implements Algorithm {
    private static final Logger LOGGER = LoggerFactory.getLogger(StrictHackathonAlgorithm.class);
    
    private static final int SDR_WIDTH = 2048;
    private static final double SPARSITY = 0.02;
    
    private RetinaApis retinaApis;
    private Network htmNetwork;
    
    private Metric similarities;
    
    private int[] currentPrediction;
    private int[] prevPrediction;
    
    private double anomaly;
    private double prevAnomaly;
    
    private List<Tweet> processedTweets;
    private List<Tweet> anomalousTweets;
    private List<Tweet> highSimilarityTweets;
    
    private Tweet currentTweet;
    
    
    
    /** Ensures synchronous processing between input and listener */
    private Semaphore semaphore;
    <commit_msg>Fix for sparsity defaulting to 2048 columns<commit_after>package org.numenta.nupic.examples.cortical_io.breakingnews;

import gnu.trove.list.array.TIntArrayList;
import io.cortical.rest.model.Fingerprint;
import io.cortical.rest.model.Metric;
import io.cortical.services.RetinaApis;
import io.cortical.services.api.client.ApiException;
import io.cortical.twitter.Algorithm;
import io.cortical.twitter.Tweet;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Semaphore;

import org.numenta.nupic.network.Inference;
import org.numenta.nupic.network.Network;
import org.numenta.nupic.util.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import rx.Subscriber;

import com.fasterxml.jackson.core.JsonProcessingException;

/**
 * An implementation of {@link Algorithm} that closely follows the original
 * logic used for the hackathon hack (as opposed to other experimental variations
 * this author may propose).
 * 
 * @author cogmission
 * @see Algorithm
 */
public class StrictHackathonAlgorithm implements Algorithm {
    private static final Logger LOGGER = LoggerFactory.getLogger(StrictHackathonAlgorithm.class);
    
    private static final int SDR_WIDTH = 16384;
    private static final double SPARSITY = 0.02;
    
    private RetinaApis retinaApis;
    private Network htmNetwork;
    
    private Metric similarities;
    
    private int[] currentPrediction;
    private int[] prevPrediction;
    
    private double anomaly;
    private double prevAnomaly;
    
    private List<Tweet> processedTweets;
    private List<Tweet> anomalousTweets;
    private List<Tweet> highSimilarityTweets;
    
    private Tweet currentTweet;
    
    
    
    /** Ensures synchronous processing between input and listener */
    private Semaphore semaphore;
    
{'fraction_non_alphanumeric': 0.07837909890695814, 'fraction_numerical': 0.006131698213809651, 'mean_word_length': 4.203883495145631, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7155719', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1111, 'n_words': 282}