56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#ifndef REGEX_ANNOTATION_HDR
|
|
#define REGEX_ANNOTATION_HDR
|
|
|
|
#include <string>
|
|
#include "concordia/common/config.hpp"
|
|
#include "concordia/tokenized_sentence.hpp"
|
|
#include "concordia/concordia_exception.hpp"
|
|
#include <boost/shared_ptr.hpp>
|
|
#include <boost/regex.hpp>
|
|
#include <boost/regex/icu.hpp>
|
|
#include <unicode/unistr.h>
|
|
|
|
|
|
typedef boost::error_info<struct my_tag, std::string> my_tag_error_info;
|
|
|
|
/*!
|
|
Class for representing a regular expression annotation rule.
|
|
Holds regex pattern string for matching and default value to assign
|
|
to the annotations. Rule also has a type, given to all annotations
|
|
produced by it.
|
|
|
|
*/
|
|
class RegexRule {
|
|
public:
|
|
/*!
|
|
Constructor.
|
|
\param patternString regex pattern to match
|
|
\param annoationType type of annotation
|
|
\param value value to be assigned to the annotation
|
|
\param caseSensitive case sensitivity of the pattern
|
|
*/
|
|
RegexRule(std::string patternString,
|
|
int annotationType,
|
|
std::string value,
|
|
bool caseSensitive = true)
|
|
throw(ConcordiaException);
|
|
|
|
/*! Destructor.
|
|
*/
|
|
virtual ~RegexRule();
|
|
|
|
/*! Applies regex annotation on tokenized sentence.
|
|
\param sentence the input sentence
|
|
*/
|
|
void apply(boost::shared_ptr<TokenizedSentence> sentence);
|
|
|
|
private:
|
|
int _annotationType;
|
|
|
|
std::string _value;
|
|
|
|
boost::u32regex _pattern;
|
|
};
|
|
|
|
#endif
|