Skip to content

Instantly share code, notes, and snippets.

@firecentaur
Created November 23, 2013 06:02
Show Gist options
  • Save firecentaur/7611338 to your computer and use it in GitHub Desktop.
Save firecentaur/7611338 to your computer and use it in GitHub Desktop.
<?php
$c = new CDataProvider();
d($c);
?>
<span class="individual word">
<?php
echo $data->lemma;
$mepsenses = $data->getRelated("mepsenses",false);
$data=null;
$mepSenseModel = new Mepsenses();
$num = 0;
foreach ($mepsenses as $word_sense_pair){
$wordid = $word_sense_pair->getAttribute('wordid');
$wordid_lable = $word_sense_pair->getAttributeLabel('wordid');
$synsetid= $word_sense_pair->getAttribute('synsetid');
$synsetid_label= $word_sense_pair->getAttributeLabel('synsetid');
$casewordid= $word_sense_pair->getAttribute('casewordid');
$casewordid_label= $word_sense_pair->getAttributeLabel('casewordid');
$senseid= $word_sense_pair->getAttribute('senseid');
$senseid_label= $word_sense_pair->getAttributeLabel('senseid');
$lexid= $word_sense_pair->getAttribute('lexid');
$lexid_label= $word_sense_pair->getAttributeLabel('lexid');
$tagcount= $word_sense_pair->getAttribute('tagcount');
$tagcount_label= $word_sense_pair->getAttributeLabel('tagcount');
$sensekey= $word_sense_pair->getAttribute('sensekey');
$sensekey_label= $word_sense_pair->getAttributeLabel('sensekey');
$synset = $word_sense_pair->getRelated('synset');
$synsetid_label = $synset->getAttributeLabel('synsetid');
$synsetid= $synset->getAttribute('synsetid');
$pos_label = $synset->getAttributeLabel('pos');
$pos= $synset->getAttribute('pos');
$definition = $synset->getAttribute('definition');
$definition_label = $synset->getAttributeLabel('definition');
$commonusage= $synset->getAttribute('commonusage');
$commonusage_label= $synset->getAttributeLabel('commonusage');
$version= $synset->getAttribute('version');
$version_label= $synset->getAttributeLabel('$version');
$num+=1;
?>
<span class="wordsensepair">
<span class="number_iterator"><?php echo CHtml::encode($num); ?></span>
<span >
<span class="individual definition">
<?php echo CHtml::encode($definition); ?>
</span>
<span class="word-data">
<span class="individual wordid label"><?php echo CHtml::encode($wordid); ?>:</span>
<span class="individual wordid data"><?php echo CHtml::encode($wordid);?></span>
<span class="individual synsetid label"><?php echo CHtml::encode($synsetid_label);?>:</span>
<span class="individual synsetid data"><?php echo CHtml::encode($synsetid); ?></span>
<span class="individual pos label"><?php echo CHtml::encode($pos_label); ?>:</span>
<span class="individual pos data"><?php echo CHtml::encode($pos); ?></span>
<span class="individual version label"><?php echo CHtml::encode($version_label); ?>:</span>
<span class="individual version data"><?php echo CHtml::encode($version); ?></span>
<span class="individual common_usage label"><?php echo CHtml::encode($commonusage_label); ?>:</span>
<span class="individual common_usage data"><?php echo CHtml::encode($commonusage); ?></span>
</span>
</span>
</span>
<?php
}
?>
</span>
<?php
$this->breadcrumbs=array(
'Words',
);
$this->menu=array(
array('label'=>'Create New Dictionary Term', 'url'=>array('create')),
array('label'=>'Manage Dictionary Terms', 'url'=>array('admin')),
);
?>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_words',
)); ?>
public function actionSearch()
{
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/search.css');
if (isset($_GET["SearchSynsetsModel"]["searchTerm"])){
$searchTerm=$_GET["SearchSynsetsModel"]["searchTerm"];
$lemma =Lemmatizer::lemmatize($searchTerm);
$model = new Words();
$model->searchTerm=$lemma;
$dataProvider= $model->searchForWord();
$searchModel= new SearchSynsetsModel();
$this->render('searchResults', array(
'dataProvider' => $dataProvider,
'searchModel'=>$searchModel
));
}
}
class Words extends CActiveRecord
{
public $searchTerm;
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'words';
}
public function searchForWord(){
$criteria=new CDbCriteria(
array(
'with'=>array(
'mepsenses.synset',
),
'condition' => "lemma=:lemma", // no quotes around :match
'params' => array(':lemma' => $this->searchTerm) // Aha! Wildcards go here
)
);
$dataProvider=new CActiveDataProvider('Words',
array(
'pagination'=>array('pageSize'=>15),
'criteria'=>$criteria,
)
);
return $dataProvider;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment