def remove_double_negative(french_sentence):
  """In french, there are TWO negative words in a negative sentence.
  for example, 'je NE peux PAS'.  Both of those will translate to
  'not', changing te meaning of the sentence in direct translation.
  This function remove the 'NE' or 'n' to prevent this.
  """
  tokens = TranslateUtils.get_list_of_words(french_sentence)
  result_tokens = []
  for i in xrange(len(tokens)):
    token = tokens[i]
    # If token is negative prefix and a token within three 3 spaces is
    # 'pas', then we are confident that this should be removed.
    if _token_is_negative_prefix(token) and _list_intersect(negatives,tokens[i+1:i+6]):
      continue
    else:
      result_tokens.append(token)
  return ' '.join(result_tokens)
 def translate(self, sentence, delims=",' ", remove=''):
   sentence = self._get_preprocessed_sentence(sentence)
   tokens = TranslateUtils.get_list_of_words(sentence, delims, remove)
   translated_list = []
   for token in tokens:
     stemmed_token = self.french_stemmer.stem(token).lower()
     if stemmed_token in self.stemmed_dict:
       possible_translations = self.stemmed_dict[stemmed_token]
       if possible_translations:
         # Use first translation in the list
         translation = possible_translations[0]
         translated_list.append(translation)
     elif token in self.translation_dict:
       possible_translations = self.translation_dict[token]
       if possible_translations:
         # Use first translation in the list
         translation = possible_translations[0]
         translated_list.append(translation)
   translation = ' '.join(translated_list)
   translation = self._get_postprocessed_sentence(translation)
   return translation