<commit_before>###
# Internal #
###

class SegmentMatcher
  constructor: (segment) ->
    @segment = segment.join('')

  matches: (scope) ->
    scope is @segment

class TrueMatcher
  constructor: ->

  matches: ->
    true

class ScopeMatcher
  constructor: (first, others) ->
    @segments = [first]
    @segments.push(segment[1]) for segment in others

  matches: (scope) ->
    scopeSegments = scope.split('.')
    return false if scopeSegments.length < @segments.length

    for segment, index in @segments
      return false unless segment.matches(scopeSegments[index])

    true

class PathMatcher
  constructor: (first, others) ->
    @matchers = [first]
    @matchers.push(matcher[1]) for matcher in others

  matches: (scopes) ->
    index = 0
    matcher = @matchers[index]
    for scope in scopes
      matcher = @matchers[++index] if matcher.matches(scope)
      return true unless matcher?
    false

class OrMatcher
  constructor: (@left, @right) ->

  matches: (scopes) ->
    @left.matches(scopes) or @right.matches(scopes)

class AndMatcher
  constructor: (@left, @right) ->

  matches: (scopes) ->
    @left.matches(scopes) and @right.matches(scopes)

class NegateMatcher
  constructor: (@left, @right) ->

  matches: (scopes) ->
    @left.matches(scopes) and not @right.matches(scopes)

class CompositeMatcher
  constructor: (left, operator, right) ->
    switch operator
      when '|' then @matcher = new OrMatcher(left, right)
      when '&' then @matcher = new AndMatcher(left, right)
      when '-' then @matcher = new NegateMatcher(left, right)

  matches: (scopes) ->
    @matcher.matches(scopes)

module.exports = {
  AndMatcher
  TrueMatcher
  CompositeMatcher
  NegateMatcher
  OrMatcher
  PathMatcher
  ScopeMatcher
  SegmentMatcher
}<commit_msg>Alphabetize class exports<commit_after>###
# Internal #
###

class SegmentMatcher
  constructor: (segment) ->
    @segment = segment.join('')

  matches: (scope) ->
    scope is @segment

class TrueMatcher
  constructor: ->

  matches: ->
    true

class ScopeMatcher
  constructor: (first, others) ->
    @segments = [first]
    @segments.push(segment[1]) for segment in others

  matches: (scope) ->
    scopeSegments = scope.split('.')
    return false if scopeSegments.length < @segments.length

    for segment, index in @segments
      return false unless segment.matches(scopeSegments[index])

    true

class PathMatcher
  constructor: (first, others) ->
    @matchers = [first]
    @matchers.push(matcher[1]) for matcher in others

  matches: (scopes) ->
    index = 0
    matcher = @matchers[index]
    for scope in scopes
      matcher = @matchers[++index] if matcher.matches(scope)
      return true unless matcher?
    false

class OrMatcher
  constructor: (@left, @right) ->

  matches: (scopes) ->
    @left.matches(scopes) or @right.matches(scopes)

class AndMatcher
  constructor: (@left, @right) ->

  matches: (scopes) ->
    @left.matches(scopes) and @right.matches(scopes)

class NegateMatcher
  constructor: (@left, @right) ->

  matches: (scopes) ->
    @left.matches(scopes) and not @right.matches(scopes)

class CompositeMatcher
  constructor: (left, operator, right) ->
    switch operator
      when '|' then @matcher = new OrMatcher(left, right)
      when '&' then @matcher = new AndMatcher(left, right)
      when '-' then @matcher = new NegateMatcher(left, right)

  matches: (scopes) ->
    @matcher.matches(scopes)

module.exports = {
  AndMatcher
  CompositeMatcher
  NegateMatcher
  OrMatcher
  PathMatcher
  ScopeMatcher
  SegmentMatcher
  TrueMatcher
}
{'fraction_non_alphanumeric': 0.12170499158721257, 'fraction_numerical': 0.0016825574873808188, 'mean_word_length': 3.431055900621118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '2395398', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1117, 'n_words': 300}