<commit_before>package com.twitter.util

import java.util.concurrent.TimeUnit
import com.google.common.collect.{MapMaker => GoogleMapMaker}
import collection.JavaConversions.JConcurrentMapWrapper

object MapMaker {
  def apply[K, V](f: Config[K, V] => Unit) = {
    val config = new Config[K, V]
    f(config)
    config()
  }

  class Config[K, V] {
    private val mapMaker = new GoogleMapMaker
    private var valueOperation: Option[K => V] = None

    def weakKeys = { mapMaker.weakKeys; this }
    def weakValues = { mapMaker.weakValues; this }
    def softKeys = { mapMaker.softKeys; this }
    def softValues = { mapMaker.softValues; this }
    def concurrencyLevel(level: Int) = { mapMaker.concurrencyLevel(level); this }
    def initialCapacity(capacity: Int) = { mapMaker.initialCapacity(capacity); this }
    def expiration(expiration: Duration) = { mapMaker.expiration(expiration.inMillis, TimeUnit.MILLISECONDS); this }
    def compute(_valueOperation: K => V) = { valueOperation = Some(_valueOperation); this }

    def apply(): collection.mutable.ConcurrentMap[K, V] = {
      val javaMap = valueOperation map { valueOperation =>
        mapMaker.makeComputingMap[K, V](new com.google.common.base.Function[K, V] {
          def apply(k: K) = valueOperation(k)
        })
      } getOrElse(mapMaker.makeMap())
      new JConcurrentMapWrapper(javaMap) {
        // the default contains method (in 2.8) calls 'get' which fucks
        // with the compute method, so we need to override contains
        // to use containsKey
        override def contains(k: K) = underlying.containsKey(k)
      }
    }
  }
}
<commit_msg>scrubbing our language. we were naughty<commit_after>package com.twitter.util

import java.util.concurrent.TimeUnit
import com.google.common.collect.{MapMaker => GoogleMapMaker}
import collection.JavaConversions.JConcurrentMapWrapper

object MapMaker {
  def apply[K, V](f: Config[K, V] => Unit) = {
    val config = new Config[K, V]
    f(config)
    config()
  }

  class Config[K, V] {
    private val mapMaker = new GoogleMapMaker
    private var valueOperation: Option[K => V] = None

    def weakKeys = { mapMaker.weakKeys; this }
    def weakValues = { mapMaker.weakValues; this }
    def softKeys = { mapMaker.softKeys; this }
    def softValues = { mapMaker.softValues; this }
    def concurrencyLevel(level: Int) = { mapMaker.concurrencyLevel(level); this }
    def initialCapacity(capacity: Int) = { mapMaker.initialCapacity(capacity); this }
    def expiration(expiration: Duration) = { mapMaker.expiration(expiration.inMillis, TimeUnit.MILLISECONDS); this }
    def compute(_valueOperation: K => V) = { valueOperation = Some(_valueOperation); this }

    def apply(): collection.mutable.ConcurrentMap[K, V] = {
      val javaMap = valueOperation map { valueOperation =>
        mapMaker.makeComputingMap[K, V](new com.google.common.base.Function[K, V] {
          def apply(k: K) = valueOperation(k)
        })
      } getOrElse(mapMaker.makeMap())
      new JConcurrentMapWrapper(javaMap) {
        // the default contains method (in 2.8) calls 'get' which messes
        // with the compute method, so we need to override contains
        // to use containsKey
        override def contains(k: K) = underlying.containsKey(k)
      }
    }
  }
}

{'fraction_non_alphanumeric': 0.11205587610081992, 'fraction_numerical': 0.0012146978439113271, 'mean_word_length': 3.397863818424566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '4152880', 'n_tokens_mistral': 1029, 'n_tokens_neox': 1017, 'n_words': 255}