<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>greeklexattribs.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>greeklexattribs.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> *</font>
00003 <font class="comment"> * greeklexattribs - SWFilter decendant to set entry attributes for greek</font>
00004 <font class="comment"> * lexicons</font>
00005 <font class="comment"> */</font>
00006
00007
00008 <font class="preprocessor">#include <stdlib.h></font>
00009 <font class="preprocessor">#include <string.h></font>
00010 <font class="preprocessor">#include <greeklexattribs.h></font>
00011 <font class="preprocessor">#include <swmodule.h></font>
00012
00013
00014 GreekLexAttribs::GreekLexAttribs() {
00015 }
00016
00017
00018 <font class="keywordtype">char</font> GreekLexAttribs::ProcessText(<font class="keywordtype">char</font> *text, <font class="keywordtype">int</font> maxlen, <font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *key, <font class="keyword">const</font> <a class="code" href="class_s_w_module.html">SWModule</a> *module) {
00019
00020 <font class="keywordflow">if</font> (module-><a class="code" href="class_s_w_module.html#a64">isProcessEntryAttributes</a>()) {
00021 <font class="keywordtype">char</font> *from;
00022 <font class="keywordtype">bool</font> inAV = <font class="keyword">false</font>;
00023 string phrase;
00024 string freq;
00025 <font class="keywordtype">char</font> val[128], *valto;
00026 <font class="keywordtype">char</font> wordstr[7];
00027 <font class="keywordtype">char</font> *currentPhrase = 0, *ch = 0;
00028 <font class="keywordtype">char</font> *currentPhraseEnd = 0;
00029 <font class="keywordtype">int</font> number = 0;
00030
00031
00032 <font class="keywordflow">for</font> (from = text; *from; from++) {
00033 <font class="keywordflow">if</font> (inAV) {
00034 <font class="keywordflow">if</font> (currentPhrase == 0) {
00035 <font class="keywordflow">if</font> (isalpha(*from))
00036 currentPhrase = from;
00037 }
00038 <font class="keywordflow">else</font> {
00039 <font class="keywordflow">if</font> ((!isalpha(*from)) && (*from != <font class="charliteral">' '</font>) && (*from != <font class="charliteral">'+'</font>) && (*from !=<font class="charliteral">'('</font>) && (*from != <font class="charliteral">')'</font>) && (*from != <font class="charliteral">'\''</font>)) {
00040 <font class="keywordflow">if</font> (*from == <font class="charliteral">'<'</font>) {
00041 <font class="keywordflow">if</font> (!currentPhraseEnd)
00042 currentPhraseEnd = from - 1;
00043 <font class="keywordflow">for</font> (; *from && *from != <font class="charliteral">'>'</font>; from++) {
00044 <font class="keywordflow">if</font> (!strncmp(from, <font class="stringliteral">"value=\""</font>, 7)) {
00045 valto = val;
00046 from += 7;
00047 <font class="keywordflow">for</font> (<font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> i = 0; from[i] != <font class="charliteral">'\"'</font> && i < 127; i++)
00048 *valto++ = from[i];
00049 *valto = 0;
00050 sprintf(wordstr, <font class="stringliteral">"%03d"</font>, number+1);
00051 module-><a class="code" href="class_s_w_module.html#a62">getEntryAttributes</a>()[<font class="stringliteral">"AVPhrase"</font>][wordstr][<font class="stringliteral">"CompoundedWith"</font>] = val;
00052 from += strlen(val);
00053 }
00054 }
00055 <font class="keywordflow">continue</font>;
00056 }
00057
00058 phrase = <font class="stringliteral">""</font>;
00059 phrase.append(currentPhrase, (<font class="keywordtype">int</font>)(((currentPhraseEnd)?currentPhraseEnd:from) - currentPhrase)-1);
00060 currentPhrase = from;
00061 <font class="keywordflow">while</font> (*from && isdigit(*from)) from++;
00062 freq = <font class="stringliteral">""</font>;
00063 freq.append(currentPhrase, (<font class="keywordtype">int</font>)(from - currentPhrase));
00064 <font class="keywordflow">if</font> ((freq.length() > 0) && (phrase.length() > 0)) {
00065 sprintf(wordstr, <font class="stringliteral">"%03d"</font>, ++number);
00066 <font class="keywordflow">if</font> ((strchr(phrase.c_str(), <font class="charliteral">'('</font>) > phrase.c_str()) && (strchr(phrase.c_str(), <font class="charliteral">')'</font>) > phrase.c_str() + 1)) {
00067 string tmp = phrase.substr(0, phrase.find_first_of(<font class="stringliteral">"("</font>));
00068 phrase.erase(phrase.find_first_of(<font class="stringliteral">"("</font>), 1);
00069 phrase.erase(phrase.find_first_of(<font class="stringliteral">")"</font>), 1);
00070 phrase.erase(0,phrase.find_first_not_of(<font class="stringliteral">"\r\n\v\t "</font>)); phrase.erase(phrase.find_last_not_of(<font class="stringliteral">"\r\n\v\t "</font>)+1);
00071 module-><a class="code" href="class_s_w_module.html#a62">getEntryAttributes</a>()[<font class="stringliteral">"AVPhrase"</font>][wordstr][<font class="stringliteral">"Alt"</font>] = phrase;
00072 phrase = tmp;
00073 }
00074 phrase.erase(0,phrase.find_first_not_of(<font class="stringliteral">"\r\n\v\t "</font>)); phrase.erase(phrase.find_last_not_of(<font class="stringliteral">"\r\n\v\t "</font>)+1);
00075 freq.erase(0,freq.find_first_not_of(<font class="stringliteral">"\r\n\v\t "</font>)); freq.erase(freq.find_last_not_of(<font class="stringliteral">"\r\n\v\t "</font>)+1);
00076 module-><a class="code" href="class_s_w_module.html#a62">getEntryAttributes</a>()[<font class="stringliteral">"AVPhrase"</font>][wordstr][<font class="stringliteral">"Phrase"</font>] = phrase;
00077 module-><a class="code" href="class_s_w_module.html#a62">getEntryAttributes</a>()[<font class="stringliteral">"AVPhrase"</font>][wordstr][<font class="stringliteral">"Frequency"</font>] = freq;
00078 currentPhrase = 0;
00079 currentPhraseEnd = 0;
00080 }
00081 }
00082 }
00083 <font class="keywordflow">if</font> (*from == <font class="charliteral">';'</font>) inAV = <font class="keyword">false</font>;
00084
00085 }
00086 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strncmp(from, <font class="stringliteral">"AV-"</font>, 3)) {
00087 inAV = <font class="keyword">true</font>;
00088 from+=2;
00089 }
00090 }
00091 }
00092 <font class="keywordflow">return</font> 0;
00093 }
00094
00095
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:12:59 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>