The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OSISMorphSegmentation Class Reference

#include <osismorphsegmentation.h>

+ Inheritance diagram for OSISMorphSegmentation:
+ Collaboration diagram for OSISMorphSegmentation:

Public Member Functions

virtual const char * getHeader () const
 
virtual const char * getOptionName ()
 
virtual const char * getOptionTip ()
 
virtual const char * getOptionValue ()
 
virtual StringList getOptionValues ()
 
bool isBoolean ()
 
 OSISMorphSegmentation ()
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 
virtual void setOptionValue (const char *ival)
 
virtual ~OSISMorphSegmentation ()
 

Protected Attributes

bool isBooleanVal
 
bool option
 
SWBuf optionValue
 
const char * optName
 
const char * optTip
 
const StringListoptValues
 

Detailed Description

Definition at line 35 of file osismorphsegmentation.h.

Constructor & Destructor Documentation

OSISMorphSegmentation::OSISMorphSegmentation ( )

Definition at line 47 of file osismorphsegmentation.cpp.

48 }
static const StringList * oValues()
static const char oName[]
static const char oTip[]
OSISMorphSegmentation::~OSISMorphSegmentation ( )
virtual

Definition at line 51 of file osismorphsegmentation.cpp.

51 {}

Member Function Documentation

virtual const char* SWFilter::getHeader ( ) const
inlinevirtualinherited

This method can supply a header associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

Reimplemented in OSISLaTeX, OSISXHTML, ThMLLaTeX, ThMLXHTML, TEIXHTML, GBFLaTeX, and GBFXHTML.

Definition at line 62 of file swfilter.h.

62 { return ""; }
virtual const char* SWOptionFilter::getOptionName ( )
inlinevirtualinherited

gets the name of the option of this filter

Returns
option name

Reimplemented in UTF8Transliterator.

Definition at line 72 of file swoptfilter.h.

72 { return optName; }
const char * optName
Definition: swoptfilter.h:51
virtual const char* SWOptionFilter::getOptionTip ( )
inlinevirtualinherited

gets a short explanation of the option of this filter; it could be presented to the user in frontend programs

Returns
option tip/explanation

Reimplemented in UTF8Transliterator.

Definition at line 78 of file swoptfilter.h.

78 { return optTip; }
const char * optTip
Definition: swoptfilter.h:52
const char * SWOptionFilter::getOptionValue ( )
virtualinherited
Returns
The value of the current option.

Reimplemented in UTF8Transliterator.

Definition at line 62 of file swoptfilter.cpp.

62  {
63  return optionValue;
64 }
SWBuf optionValue
Definition: swoptfilter.h:50
virtual StringList SWOptionFilter::getOptionValues ( )
inlinevirtualinherited

returns a list of the possible option values

Returns
list of option values

Reimplemented in UTF8Transliterator.

Definition at line 84 of file swoptfilter.h.

84 { return *optValues; }
const StringList * optValues
Definition: swoptfilter.h:53
bool SWOptionFilter::isBoolean ( )
inlineinherited

many options are simple Off/On boolean type, and frontends may wish to show these with checkmarks or the like to the end user. This is a convenience method to allow a frontend to check if this filter has only Off/On values

Definition at line 67 of file swoptfilter.h.

67 { return isBooleanVal; }
char OSISMorphSegmentation::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
)
virtual

This method processes and appropriately modifies the text given it for a particular filter task

Parameters
textThe text to be filtered/converted
keyCurrent key That was used.
moduleCurrent module.
Returns
0

Implements SWFilter.

Definition at line 54 of file osismorphsegmentation.cpp.

54  {
55  SWBuf token;
56  bool intoken = false;
57  bool hide = false;
58 
59  SWBuf orig( text );
60  const char *from = orig.c_str();
61 
62  XMLTag tag;
63  SWBuf tagText = "";
64  unsigned int morphemeNum = 0;
65  bool inMorpheme = false;
66  SWBuf buf;
67 
68  for (text = ""; *from; ++from) {
69  if (*from == '<') {
70  intoken = true;
71  token = "";
72  continue;
73  }
74 
75  if (*from == '>') { // process tokens
76  intoken = false;
77 
78  if (!strncmp(token.c_str(), "seg ", 4) || !strncmp(token.c_str(), "/seg", 4)) {
79  tag = token;
80 
81  if (!tag.isEndTag() && tag.getAttribute("type") &&
82  ( !strcmp("morph", tag.getAttribute("type"))
83  || !strcmp("x-morph", tag.getAttribute("type")))) { // <seg type="morph"> start tag
84  hide = !option; //only hide if option is Off
85  tagText = "";
86  inMorpheme = true;
87  }
88 
89  if (tag.isEndTag() && inMorpheme) {
90  buf.setFormatted("%.3d", morphemeNum++);
91  module->getEntryAttributes()["Morpheme"][buf]["body"] = tagText;
92  inMorpheme = false;
93  }
94  if (hide) { //hides start and end tags as long as hide is set
95 
96  if (tag.isEndTag()) { // </seg>
97  hide = false;
98  }
99 
100  continue; //leave out the current token
101  }
102  } //end of seg tag handling
103 
104  text.append('<');
105  text.append(token);
106  text.append('>');
107 
108  if (inMorpheme) {
109  tagText.append('<');
110  tagText.append(token);
111  tagText.append('>');
112  }
113 
114  hide = false;
115 
116  continue;
117  } //end of intoken part
118 
119  if (intoken) { //copy token
120  token.append(*from);
121  }
122  else { //copy text which is not inside of a tag
123  text.append(*from);
124  if (inMorpheme) {
125  tagText.append(*from);
126  }
127  }
128  }
129  return 0;
130 }
Definition: swbuf.h:47
Definition: utilxml.h:38
const char * c_str() const
Definition: swbuf.h:158
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
virtual AttributeTypeList & getEntryAttributes() const
Definition: swmodule.h:817
const char * getAttribute(const char *attribName, int partNum=-1, char partSplit= '|') const
Definition: utilxml.cpp:230
bool isEndTag(const char *eID=0) const
Definition: utilxml.cpp:323
SWBuf & setFormatted(const char *format,...)
Definition: swbuf.cpp:50
void SWOptionFilter::setOptionValue ( const char *  ival)
virtualinherited

sets the value of the option of this filter, e.g maybe a strong's filter might be set to "On" / "Off" - that would mean to show or not to show the strongs in the text, see also getOptionValues()

Parameters
ivalthe new option value

Reimplemented in UTF8Transliterator.

Definition at line 52 of file swoptfilter.cpp.

52  {
53  for (StringList::const_iterator loop = optValues->begin(); loop != optValues->end(); loop++) {
54  if (!stricmp(loop->c_str(), ival)) {
55  optionValue = *loop;
56  option = (!strnicmp(ival, "On", 2)); // convenience for boolean filters
57  break;
58  }
59  }
60 }
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
SWBuf optionValue
Definition: swoptfilter.h:50
int strnicmp(const char *s1, const char *s2, int len)
Definition: utilstr.cpp:180
const StringList * optValues
Definition: swoptfilter.h:53

Member Data Documentation

bool SWOptionFilter::isBooleanVal
protectedinherited

Definition at line 55 of file swoptfilter.h.

bool SWOptionFilter::option
protectedinherited

Definition at line 54 of file swoptfilter.h.

SWBuf SWOptionFilter::optionValue
protectedinherited

Definition at line 50 of file swoptfilter.h.

const char* SWOptionFilter::optName
protectedinherited

Definition at line 51 of file swoptfilter.h.

const char* SWOptionFilter::optTip
protectedinherited

Definition at line 52 of file swoptfilter.h.

const StringList* SWOptionFilter::optValues
protectedinherited

Definition at line 53 of file swoptfilter.h.


The documentation for this class was generated from the following files: