<commit_before><?php
/**
 * Behavior to be used with models that have atrributes to be linked with ProlinkKey.
 * This Behavior is working with prolink_content table.
 */
class ProlinkContentBehavior extends CActiveRecordBehavior{

	public $attributes = array();
		
	
	public function afterDelete($event){		
		Yii::app()->db->delete('prolink_content', array('model'=> get_class($this->getOwner()) , 'model_id'=> $this->getNormalizedPk() ) );
		return parent::afterDelete($event);
	}

	/**
	 * Return pro-linked version of the text.
	 * Todo: its necessary to implement shadow relation to avoid another query for linked text.
	 * When performance is slow try to use memcached server. 
	 * Optionally use some FAST no-sql database or key-value service. This approach seems to be much more faster 
	 * than traditional DB table storage. 
	 */<commit_msg>added delete content in afterSave<commit_after><?php
/**
 * Behavior to be used with models that have atrributes to be linked with ProlinkKey.
 * This Behavior is working with prolink_content table.
 */
class ProlinkContentBehavior extends CActiveRecordBehavior{

	public $attributes = array();
		
	
	public function afterDelete($event){		
		Yii::app()->db->delete('prolink_content', array('model'=> get_class($this->getOwner()) , 'model_id'=> $this->getNormalizedPk() ) );
		return parent::afterDelete($event);
	}

	/**
	 * Delete cached content when a record was changes. 
	 * todo: store old values of prolinked attributes and delete only in
	 * case those have been changed.  
	 */
	public function afterSave($event){
		Yii::app()->db->delete('prolink_content', array('model'=> get_class($this->getOwner()) , 'model_id'=> $this->getNormalizedPk() ) );
		return parent::afterSave($event);
	}
	
	/**
	 * Return pro-linked version of the text.
	 * Todo: its necessary to implement shadow relation to avoid another query for linked text.
	 * When performance is slow try to use memcached server. 
	 * Optionally use some FAST no-sql database or key-value service. This approach seems to be much more faster 
	 * than traditional DB table storage. 
	 */
{'fraction_non_alphanumeric': 0.11079410366143605, 'fraction_numerical': 0.0, 'mean_word_length': 4.36734693877551, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '4651932', 'n_tokens_mistral': 599, 'n_tokens_neox': 553, 'n_words': 218}