1
/******************************************************************************
3
* greeklexattribs - SWFilter descendant to set entry attributes for greek
11
#include <greeklexattribs.h>
18
GreekLexAttribs::GreekLexAttribs() {
22
char GreekLexAttribs::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
24
if (module->isProcessEntryAttributes()) {
29
char val[128], *valto;
31
const char *currentPhrase = 0, *ch = 0;
32
const char *currentPhraseEnd = 0;
36
for (from = text.c_str(); *from; from++) {
38
if (currentPhrase == 0) {
43
if ((!isalpha(*from)) && (*from != ' ') && (*from != '+') && (*from !='(') && (*from != ')') && (*from != '\'')) {
45
if (!currentPhraseEnd)
46
currentPhraseEnd = from - 1;
47
for (; *from && *from != '>'; from++) {
48
if (!strncmp(from, "value=\"", 7)) {
51
for (unsigned int i = 0; from[i] != '\"' && i < 127; i++)
54
sprintf(wordstr, "%03d", number+1);
55
module->getEntryAttributes()["AVPhrase"][wordstr]["CompoundedWith"] = val;
63
phrase.append(currentPhrase, (int)(((currentPhraseEnd>currentPhrase)?currentPhraseEnd:from) - currentPhrase)-1);
65
while (*from && isdigit(*from)) from++;
67
freq.append(currentPhrase, (int)(from - currentPhrase));
68
if ((freq.length() > 0) && (phrase.length() > 0)) {
69
sprintf(wordstr, "%03d", ++number);
70
if ((strchr(phrase.c_str(), '(') > phrase.c_str()) && (strchr(phrase.c_str(), ')') > phrase.c_str() + 1)) {
71
string tmp = phrase.substr(0, phrase.find_first_of("("));
72
phrase.erase(phrase.find_first_of("("), 1);
73
phrase.erase(phrase.find_first_of(")"), 1);
74
phrase.erase(0,phrase.find_first_not_of("\r\n\v\t ")); phrase.erase(phrase.find_last_not_of("\r\n\v\t ")+1);
75
module->getEntryAttributes()["AVPhrase"][wordstr]["Alt"] = phrase.c_str();
78
phrase.erase(0,phrase.find_first_not_of("\r\n\v\t ")); phrase.erase(phrase.find_last_not_of("\r\n\v\t ")+1);
79
freq.erase(0,freq.find_first_not_of("\r\n\v\t ")); freq.erase(freq.find_last_not_of("\r\n\v\t ")+1);
80
module->getEntryAttributes()["AVPhrase"][wordstr]["Phrase"] = phrase.c_str();
81
module->getEntryAttributes()["AVPhrase"][wordstr]["Frequency"] = freq.c_str();
87
if (*from == ';') inAV = false;
90
else if (!strncmp(from, "AV-", 3)) {