code: def generate_relative_collation_tests(filename, weighting):
      lines = open(filename, "r").readlines()
  
      all_cps = []
      all_ranges = []
      chunk_idx = 0
      line_idx = 0
      for line in lines:
          if line_idx == 25000:
              cps_string = ", ".join(map(lambda x: "0x" + x, all_cps))
              ranges_string = ", ".join(
                  map(
                      lambda x: "{{{}, {}}}".format(x[0], x[1]),
                      all_ranges,
                  )
              )
              cpp_file = open(
                  "relative_collation_test_{0}_{1}.cpp".format(
                      weighting, chunk_idx
                  ),
                  "w",
              )
              cpp_file.write(
                  relative_collation_tests_form.format(
                      cps_string,
                      len(all_cps),
                      ranges_string,
                      len(all_ranges),
                      weighting,
                      chunk_idx,
                  )
              )
              chunk_idx += 1
              all_cps = []
              all_ranges = []
              line_idx = 0
          line = line[:-1]
          if not line.startswith("#") and len(line) != 0:
              comment_start = line.find("#")
              comment = ""
              if comment_start != -1:
                  comment = line[comment_start + 1 :].strip()
                  line = line[:comment_start]
              if "surrogate" in comment:
                  continue
              if "noncharacter" in comment:
                  continue
              cps = line.split(";")[0].split(" ")
              first = len(all_cps)
              all_cps += cps
              last = len(all_cps)
              all_ranges.append((first, last))
              line_idx += 1
  
      if line_idx != 0:
          cps_string = ", ".join(map(lambda x: "0x" + x, all_cps))
          ranges_string = ", ".join(
              map(lambda x: "{{{}, {}}}".format(x[0], x[1]), all_ranges)
          )
          cpp_file = open(
              "relative_collation_test_{0}_{1}.cpp".format(
                  weighting, chunk_idx
              ),
              "w",
          )
          cpp_file.write(
              relative_collation_tests_form.format(
                  cps_string,
                  len(all_cps),
                  ranges_string,
                  len(all_ranges),
                  weighting,
                  chunk_idx,
              )
          )
  
file_path: infinity/third_party/iresearch/external/text/scripts/generate_unicode_collation_tests.py
imports: from generate_unicode_normalization_data import cccs
  from generate_unicode_normalization_data import expand_decomp_canonical
  from generate_unicode_normalization_data import get_decompositions
  from generate_unicode_collation_data import get_frac_uca_cet
  from generate_unicode_collation_data import ce_to_cpp
  import re
  import sys
label_desc: Use image node_id 4 for calling a global function with example usage: generate_relative_collation_tests(filename, weighting) without return types