input: Write a python function to match reference and hypothesis segments in STM and CTM files.
  assert match_ref_hyp([STM_Line("file1 A 0.0 1.0 <sil> hello")], [CTM_Line("file1 A 0.5 0.5 hello")])[0].words == 'hello'
  assert match_ref_hyp([STM_Line("file2 A 0.0 2.0 <sil> world")], [CTM_Line("file2 A 1.0 0.5 world")])[0].words == 'world'
  assert len(match_ref_hyp([STM_Line("file3 A 0.0 1.0 <sil>")], [CTM_Line("file3 A 1.0 0.5 unmatched")])) == 2
output: def match_ref_hyp(stm_lines, ctm_lines):
      matches = []
      for stm in stm_lines:
          ref_start = stm.start_time
          ref_end = stm.end_time
          ref_words = stm.words
          
          found_match = False
          for ctm in ctm_lines:
              hyp_start = ctm.start_time
              hyp_end = hyp_start + ctm.duration
              hyp_words = ctm.words
              
              if stm.file_id == ctm.file_id and ref_start <= hyp_start < ref_end:
                  matches.append(STM_Line(stm.file_id, stm.channel, hyp_start, hyp_end, stm.speaker, hyp_words))
                  found_match = True
                  break
          
          if not found_match:
              matches.append(stm)
      
      for ctm in ctm_lines:
          found = False
          for match in matches:
              if match.file_id == ctm.file_id and match.words == ctm.words:
                  found = True
                  break
          if not found:
              matches.append(ctm)
      
      return matches