Add min confidence parameter to language filter
This commit is contained in:
parent
05e02aae8b
commit
6d2af1878a
2 changed files with 8 additions and 2 deletions
|
@ -35,6 +35,7 @@ function langfilter_addon_settings(&$a,&$s) {
|
||||||
|
|
||||||
$enable_checked = (intval(get_pconfig(local_user(),'langfilter','disable')) ? '' : ' checked="checked" ');
|
$enable_checked = (intval(get_pconfig(local_user(),'langfilter','disable')) ? '' : ' checked="checked" ');
|
||||||
$languages = get_pconfig(local_user(),'langfilter','languages');
|
$languages = get_pconfig(local_user(),'langfilter','languages');
|
||||||
|
$minconfidence = get_pconfig(local_user(),'langfilter','minconfidence')*100;
|
||||||
if(! $languages)
|
if(! $languages)
|
||||||
$languages = 'en,de,fr,it,es';
|
$languages = 'en,de,fr,it,es';
|
||||||
|
|
||||||
|
@ -44,6 +45,7 @@ function langfilter_addon_settings(&$a,&$s) {
|
||||||
'$intro' => t ('This addon tries to identify the language of a postings. If it does not match any language spoken by you (see below) the posting will be collapsed. Remember detecting the language is not perfect, especially with short postings.'),
|
'$intro' => t ('This addon tries to identify the language of a postings. If it does not match any language spoken by you (see below) the posting will be collapsed. Remember detecting the language is not perfect, especially with short postings.'),
|
||||||
'$enabled' => array('langfilter_enable', t('Use the language filter'), $enable_checked, ''),
|
'$enabled' => array('langfilter_enable', t('Use the language filter'), $enable_checked, ''),
|
||||||
'$languages' => array('langfilter_languages', t('I speak'), $languages, t('List of abbreviations (iso2 codes) for languages you speak, comma separated. For example "de,it".') ),
|
'$languages' => array('langfilter_languages', t('I speak'), $languages, t('List of abbreviations (iso2 codes) for languages you speak, comma separated. For example "de,it".') ),
|
||||||
|
'$minconfidence' => array('langfilter_minconfidence', t('Minimum confidence in language detection'), $minconfidence, t('Minimum confidence in language detection being correct, from 0 to 100. Posts will not be filtered when the confidence of language detection is below this percent value.') ),
|
||||||
'$submit' => t('Save Settings'),
|
'$submit' => t('Save Settings'),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -63,8 +65,11 @@ function langfilter_addon_settings_post(&$a,&$b) {
|
||||||
$enable = ((x($_POST,'langfilter_enable')) ? intval($_POST['langfilter_enable']) : 0);
|
$enable = ((x($_POST,'langfilter_enable')) ? intval($_POST['langfilter_enable']) : 0);
|
||||||
$disable = 1-$enable;
|
$disable = 1-$enable;
|
||||||
set_pconfig(local_user(),'langfilter','disable', $disable);
|
set_pconfig(local_user(),'langfilter','disable', $disable);
|
||||||
$confidence = ((x($_POST,'langfilter_minconfidence')) ? intval($_POST['langfilter_minconfidence']) : 0);
|
$minconfidence = 0+$_POST['langfilter_minconfidence'];
|
||||||
set_pconfig(local_user(),'langfilter','minconfidence', $confidence);
|
if ( ! $minconfidence ) $minconfidence = 0;
|
||||||
|
else if ( $minconfidence < 0 ) $minconfidence = 0;
|
||||||
|
else if ( $minconfidence > 100 ) $minconfidence = 100;
|
||||||
|
set_pconfig(local_user(),'langfilter','minconfidence', $minconfidence/100.0);
|
||||||
info( t('Language Filter Settings saved.') . EOL);
|
info( t('Language Filter Settings saved.') . EOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<p>{{$intro}}</p>
|
<p>{{$intro}}</p>
|
||||||
{{include file="field_checkbox.tpl" field=$enabled}}
|
{{include file="field_checkbox.tpl" field=$enabled}}
|
||||||
{{include file="field_input.tpl" field=$languages}}
|
{{include file="field_input.tpl" field=$languages}}
|
||||||
|
{{include file="field_input.tpl" field=$minconfidence}}
|
||||||
</div>
|
</div>
|
||||||
<div class="settings-submit-wrapper" >
|
<div class="settings-submit-wrapper" >
|
||||||
<input type="submit" id="langfilter-settings-submit" name="langfilter-settings-submit" class="settings-submit" value="{{$submit}}" />
|
<input type="submit" id="langfilter-settings-submit" name="langfilter-settings-submit" class="settings-submit" value="{{$submit}}" />
|
||||||
|
|
Loading…
Reference in a new issue