<commit_before><?php
class SentencesHelper extends AppHelper {

	var $helpers = array('Html', 'Form', 'Tooltip', 'Kakasi', 'Javascript');
	
	/**
	 * Display a single sentence.
	 */
	function displaySentence($sentence) {
		echo '<div class="original sentence">';
		// Sentence
		echo '<span class="correctness'.$sentence['correctness'].' '.$sentence['lang'].'">';
		echo $this->Html->link($sentence['text'], array("controller" => "sentences", "action" => "show", $sentence['id']));
		echo '</span> ';
		if($sentence['lang'] == 'jp'){
			echo '<span class="romaji">';
			$this->Kakasi->convert($sentence['text'], 'romaji');
			echo '</span>';
		}
		echo '</div>';
	}
	
	/**
	 * Display a single sentence for edit in place.
	 */
	function displayEditableSentence($sentence) {
		echo '<div class="editable original sentence">';
			// Sentence
			echo '<span id="'.$sentence['lang'].$sentence['id'].'" class="editableSentence correctness'.$sentence['correctness'].' '.$sentence['lang'].'">';
			echo $sentence['text'];
			echo '</span> ';
			if($sentence['lang'] == 'jp'){
				echo '<span class="romaji">';
				$this->Kakasi->convert($sentence['text'], 'romaji');
				echo '</span>';
			}
		echo '</div>';
	}
	
	/**
	 * Diplay a sentence and its translations.
	 */
	function displayGroup($sentence, $translations) {
		echo '<div class="sentence">';
		
		// Sentence
		echo '<div class="original correctness'.$sentence['correctness'].'">';
		echo '<span class="'.$sentence['lang'].'">'.$sentence['text'].'</span> ';
		if($sentence['lang'] == 'jp'){
			echo '<span class="romaji">';
			$this->Kakasi->convert($sentence['text'], 'romaji');
			echo '</span>';
		}
		echo '</div>';
		
		echo '<ul id="translation_for_'.$sentence['id'].'" class="addTranslations">';
		echo '</ul>';
		
		echo '<ul id="'.$sentence['id'].'_translations" class="translations">';
		if(count($translations) > 0){
			// direct translations
			$this->displayTranslations($translations, 'show');
			
			// indirect translations
			$this->displayIndirectTranslations($sentence, 'show');
		}
		echo '</ul>';
		
		echo '</div>';
    }
	 
	/**
	 * Display direct translations.
	 */
	function displayTranslations($translations, $action){			
		$controller = (preg_match("/sentence_comments|contributions/", $this->params['controller'])) ? $this->params['controller'] : "sentences";
		
		foreach($translations as $translation){
			echo '<li class="direct translation correctness'.$translation['correctness'].'">';
			echo $this->Html->link(
				$translation['text'],
				array(
					"controller" => $controller,
					"action" => $action,
					$translation['id']
				),
				array("class" => $translation['lang'])
			);
			if($translation['lang'] == 'jp'){
				echo '<span class="romaji">';
				$this->Kakasi->convert($translation['text'], 'romaji');
				echo '</span>';
			}
			echo '</li>';
		}
	}
	
	/**
	 * Display indirect translations, that is to say translations of translations.
	 */
	function displayIndirectTranslations($sentence, $action){
		if(isset($sentence['Translation'])){
			$translations = $sentence['Translation'];
			$translationsIds = array($sentence['id']);<commit_msg>Toolip for romaji, to let users know that it's automatically generated.<commit_after><?php
class SentencesHelper extends AppHelper {

	var $helpers = array('Html', 'Form', 'Tooltip', 'Kakasi', 'Javascript');
	
	/**
	 * Display a single sentence.
	 */
	function displaySentence($sentence) {
		echo '<div class="original sentence">';
		// Sentence
		echo '<span class="correctness'.$sentence['correctness'].' '.$sentence['lang'].'">';
		echo $this->Html->link($sentence['text'], array("controller" => "sentences", "action" => "show", $sentence['id']));
		echo '</span> ';
		if($sentence['lang'] == 'jp'){
			$this->displayRomaji($sentence['text']);
		}
		echo '</div>';
	}
	
	function displayRomaji($text){
		echo '<span class="romaji" title="'.__('WARNING : the romaji is automatically generated and is not always reliable.',true).'">';
			$this->Kakasi->convert($text, 'romaji');
		echo '</span>';
	}
	
	/**
	 * Display a single sentence for edit in place.
	 */
	function displayEditableSentence($sentence) {
		echo '<div class="editable original sentence">';
			// Sentence
			echo '<span id="'.$sentence['lang'].$sentence['id'].'" class="editableSentence correctness'.$sentence['correctness'].' '.$sentence['lang'].'">';
			echo $sentence['text'];
			echo '</span> ';
			if($sentence['lang'] == 'jp'){
				$this->displayRomaji($sentence['text']);
			}
		echo '</div>';
	}
	
	/**
	 * Diplay a sentence and its translations.
	 */
	function displayGroup($sentence, $translations) {
		echo '<div class="sentence">';
		
		// Sentence
		echo '<div class="original correctness'.$sentence['correctness'].'">';
		echo '<span class="'.$sentence['lang'].'">'.$sentence['text'].'</span> ';
		if($sentence['lang'] == 'jp'){
			$this->displayRomaji($sentence['text']);
		}
		echo '</div>';
		
		echo '<ul id="translation_for_'.$sentence['id'].'" class="addTranslations">';
		echo '</ul>';
		
		echo '<ul id="'.$sentence['id'].'_translations" class="translations">';
		if(count($translations) > 0){
			// direct translations
			$this->displayTranslations($translations, 'show');
			
			// indirect translations
			$this->displayIndirectTranslations($sentence, 'show');
		}
		echo '</ul>';
		
		echo '</div>';
    }
	 
	/**
	 * Display direct translations.
	 */
	function displayTranslations($translations, $action){			
		$controller = (preg_match("/sentence_comments|contributions/", $this->params['controller'])) ? $this->params['controller'] : "sentences";
		
		foreach($translations as $translation){
			echo '<li class="direct translation correctness'.$translation['correctness'].'">';
			echo $this->Html->link(
				$translation['text'],
				array(
					"controller" => $controller,
					"action" => $action,
					$translation['id']
				),
				array("class" => $translation['lang'])
			);
			if($translation['lang'] == 'jp'){
				$this->displayRomaji($translation['text']);
			}
			echo '</li>';
		}
	}
	
	/**
	 * Display indirect translations, that is to say translations of translations.
	 */
	function displayIndirectTranslations($sentence, $action){
		if(isset($sentence['Translation'])){
			$translations = $sentence['Translation'];
			$translationsIds = array($sentence['id']);
{'fraction_non_alphanumeric': 0.21796899715279974, 'fraction_numerical': 0.00031635558367605187, 'mean_word_length': 4.427467811158798, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4715343', 'n_tokens_mistral': 2294, 'n_tokens_neox': 1880, 'n_words': 401}