code: def computeChrF(
      fpRef,
      fpHyp,
      nworder=0,
      ncorder=6,
      beta=2,
      sentence_level_scores=None,
  ):
      norder = float(nworder + ncorder)
  
      # initialisation of document level scores
      totalMatchingCount = defaultdict(float)
      totalRefCount = defaultdict(float)
      totalHypCount = defaultdict(float)
      totalChrMatchingCount = defaultdict(float)
      totalChrRefCount = defaultdict(float)
      totalChrHypCount = defaultdict(float)
      averageTotalF = 0.0
  
      nsent = 0
      for hline, rline in zip(fpHyp, fpRef):
          nsent += 1
  
          # preparation for multiple references
          maxF = -1
  
          hypNgramCounts = ngram_counts(
              separate_punctuation(hline), nworder
          )
          hypChrNgramCounts = ngram_counts(
              separate_characters(hline), ncorder
          )
  
          # going through multiple references
  
          for ref in rline:
              refNgramCounts = ngram_counts(
                  separate_punctuation(ref), nworder
              )
              refChrNgramCounts = ngram_counts(
                  separate_characters(ref), ncorder
              )
  
              # number of overlapping n-grams, total number of ref n-grams, total number of hyp n-grams
              (
                  matchingNgramCounts,
                  totalRefNgramCount,
                  totalHypNgramCount,
              ) = ngram_matches(refNgramCounts, hypNgramCounts)
              (
                  matchingChrNgramCounts,
                  totalChrRefNgramCount,
                  totalChrHypNgramCount,
              ) = ngram_matches(refChrNgramCounts, hypChrNgramCounts)
  
              # n-gram f-scores, recalls and precisions
              ngramF, ngramRec, ngramPrec = ngram_precrecf(
                  matchingNgramCounts,
                  totalRefNgramCount,
                  totalHypNgramCount,
                  beta,
              )
              chrNgramF, chrNgramRec, chrNgramPrec = ngram_precrecf(
                  matchingChrNgramCounts,
                  totalChrRefNgramCount,
                  totalChrHypNgramCount,
                  beta,
              )
  
              sentRec = (
                  sum(chrNgramRec.values()) + sum(ngramRec.values())
              ) / norder
              sentPrec = (
                  sum(chrNgramPrec.values()) + sum(ngramPrec.values())
              ) / norder
              sentF = (
                  sum(chrNgramF.values()) + sum(ngramF.values())
              ) / norder
  
              if sentF > maxF:
                  maxF = sentF
                  bestMatchingCount = matchingNgramCounts
                  bestRefCount = totalRefNgramCount
                  bestHypCount = totalHypNgramCount
                  bestChrMatchingCount = matchingChrNgramCounts
                  bestChrRefCount = totalChrRefNgramCount
                  bestChrHypCount = totalChrHypNgramCount
          # all the references are done
  
          # write sentence level scores
          if sentence_level_scores:
              sentence_level_scores.write(
                  "%i::c%i+w%i-F%i\t%.4f\n"
                  % (nsent, ncorder, nworder, beta, 100 * maxF)
              )
  
          # collect document level ngram counts
          for order in range(nworder):
              totalMatchingCount[order] += bestMatchingCount[order]
              totalRefCount[order] += bestRefCount[order]
              totalHypCount[order] += bestHypCount[order]
          for order in range(ncorder):
              totalChrMatchingCount[order] += bestChrMatchingCount[
                  order
              ]
              totalChrRefCount[order] += bestChrRefCount[order]
              totalChrHypCount[order] += bestChrHypCount[order]
  
          averageTotalF += maxF
  
      # all sentences are done
  
      # total precision, recall and F (aritmetic mean of all ngrams)
      totalNgramF, totalNgramRec, totalNgramPrec = ngram_precrecf(
          totalMatchingCount, totalRefCount, totalHypCount, beta
      )
      (
          totalChrNgramF,
          totalChrNgramRec,
          totalChrNgramPrec,
      ) = ngram_precrecf(
          totalChrMatchingCount,
          totalChrRefCount,
          totalChrHypCount,
          beta,
      )
  
      totalF = (
          sum(totalChrNgramF.values()) + sum(totalNgramF.values())
      ) / norder
      # averageTotalF = averageTotalF / nsent
      # totalRec  = (sum(totalChrNgramRec.values())  + sum(totalNgramRec.values()))  / norder
      # totalPrec = (sum(totalChrNgramPrec.values()) + sum(totalNgramPrec.values())) / norder
  
      return totalF
  
file_path: TextBox/textbox/evaluator/utils/chrf.py
imports: import sys
  import math
  import unicodedata
  import argparse
  from collections import defaultdict
  import time
  import string
label_desc: Use image node_id 6 for calling a global function with example usage: computeChrF(fpRef, fpHyp, nworder, ncorder, beta, sentence_level_scores) and returns: totalF