function apachesolr_multilingual_validate_solr_textfile in Apache Solr Multilingual 6.2
Same name and namespace in other branches
- 6 apachesolr_multilingual_textfile/apachesolr_multilingual_textfile.module \apachesolr_multilingual_validate_solr_textfile()
1 call to apachesolr_multilingual_validate_solr_textfile()
- apachesolr_multilingual_textfile_nodeapi in apachesolr_multilingual_textfile/
apachesolr_multilingual_textfile.module
File
- apachesolr_multilingual_textfile/
apachesolr_multilingual_textfile.module, line 371
Code
function apachesolr_multilingual_validate_solr_textfile($filename, $text) {
$message = '';
// remove comments for checkup and split body in lines
$text = preg_replace('/\\s*$/', '', $text);
$text = preg_replace('/^\\s*/', '', $text);
$lines = explode("\n", $text);
foreach ($lines as $i => $line) {
if (drupal_substr($line, 0, 1) == '#' || trim($line) == '') {
unset($lines[$i]);
}
}
// parser
switch ($filename) {
case 'stopwords.txt':
foreach ($lines as $i => $line) {
$words = explode(" ", $line);
if (count($words) > 1) {
$message = drupal_strtoupper('line ' . $i . ': (' . $line . ')');
break;
}
}
break;
case 'synonyms.txt':
foreach ($lines as $i => $line) {
$words = explode(" ", $line);
if (count($words) < 3) {
$message = drupal_strtoupper('line ' . $i . ': (' . $line . ')');
break;
}
if ($words[1] != '=>') {
$message = drupal_strtoupper('line ' . $i . ': missing => (' . $line . ')');
break;
}
}
break;
case 'protwords.txt':
foreach ($lines as $i => $line) {
$words = explode(" ", $line);
if (count($words) > 1) {
$message = drupal_strtoupper('line ' . $i . ': (' . $line . ')');
break;
}
}
break;
case 'compoundwords.txt':
break;
}
return $message;
}