 frequency_lists = require('./frequency_lists')
 adjacency_graphs = require('./adjacency_graphs')
+scoring = require('./scoring')
 
 build_ranked_dict = (ordered_list) ->
   result = {}

    if year > 99
      year
    else if year > 50
      year + 1900 # 87 -> 1987
    else
      year + 2000 # 15 -> 2015


module.exports = matching

          candidates.push dmy if dmy?
        continue unless candidates.length > 0
        # at this point: different possible dmy mappings for the same i,j substring.
        # match the candidate date that has smallest entropy: a year closest to 2000.
        # (scoring.REFERENCE_YEAR).
        #
        # ie, considering '111504', prefer 11-15-04 to 1-1-1504
        # (interpreting '04' as 2004)
        best_candidate = candidates[0]
        metric = (candidate) -> Math.abs candidate.year - scoring.REFERENCE_YEAR
        min_distance = metric candidates[0]
        for candidate in candidates[1..]
          distance = metric candidate
          if distance < min_distance
            [best_candidate, min_distance] = [candidate, distance]
        matches.push
