code: def detect(self, text):
      
      t = text.encode("utf-8")
      reliable, index, top_3_choices = cld2.detect(t, bestEffort=False)
  
      if not reliable:
        self.reliable = False
        reliable, index, top_3_choices = cld2.detect(t, bestEffort=True)
        
        if not self.quiet:
          if not reliable:
            raise UnknownLanguage("Try passing a longer snippet of text")
          else:
            logger.warning("Detector is not able to detect the language reliably.")
  
      self.languages = [Language(x) for x in top_3_choices]
      self.language = self.languages[0]
      return self.language
docs: Decide which language is used to write the text.
  
      The method tries first to detect the language with high reliability. If
      that is not possible, the method switches to best effort strategy.
  
  
      Args:
        text (string): A snippet of text, the longer it is the more reliable we
                       can detect the language used to write the text.