class_docstr: Transliterator between pair of languages. 
class_docstr_tok: ["Transliterator","between","pair","of","languages","."]
code: def _transliterate_string(weight, ngram1=6, ngram2=6):
      def translate_string(word):
          unlimited5 = 99999
          # Convert input to lower case
          word = word.lower().strip()
          # Initialize bestk results
          best_source_string = []
          best_target_string = []
          best_string_cost = []
          for i in range(len(word) + 1):
              best_source_string.append("")
              best_target_string.append("")
              best_string_cost.append(unlimited5)
          # Only 1 initial state
          best_string_cost[0] = 0
          # Start DP to generate bestk results
          for i in range(1, len(word) + 1):
              for j in range(1, ngram1 + 1):
                  if i >= j:
                      piece = word[i - j : i]
                      for item in weight:
                          if item[0].strip() == piece:
                              vfinal = -log(weight[item])
                              if best_string_cost[i - j] < unlimited5:
                                  tmp_string_cost = best_string_cost[
                                      i - j
                                  ]
                                  # Final cost value.
                                  # Things need to be considered:
                                  # 1) Individual cost of tranliterating from piece to tar
                                  # 2) Length of piece and tar
                                  # 3) Prefix of piece
                                  # 4) Prefix of tar
                                  tmp_string_cost += vfinal
                                  if (
                                      tmp_string_cost
                                      < best_string_cost[i]
                                  ):
                                      tmp_source_string = (
                                          best_source_string[i - j]
                                          + piece
                                      )
                                      tmp_target_string = (
                                          best_target_string[i - j]
                                          + item[1].strip()
                                      )
                                      best_source_string[
                                          i
                                      ] = tmp_source_string
                                      best_target_string[
                                          i
                                      ] = tmp_target_string
                                      best_string_cost[
                                          i
                                      ] = tmp_string_cost
          return best_target_string[len(word)]
  
      return translate_string
  
file_path: polyglot/polyglot/transliteration/base.py
imports: from math import log
  from ..load import load_transliteration_table
  from ..decorators import cached_property
label_desc: Use image node_id 6 for calling the Transliterator obj's underlying member method code with example usage: obj._transliterate_string(weight, ngram1, ngram2) and returns: translate_string, best_target_string