Sha256: 9e5f30885077b69c04126795b933a38e7500089baa57e6410dbf17efad6a8aef

Contents?: true

Size: 1022 Bytes

Versions: 8

Compression:

Stored size: 1022 Bytes

Contents

#ifndef __porter_stemmer_h__
#define __porter_stemmer_h__
#include "inplace_processor.h"

// from porter_stemmer_original.c
extern "C" {
  struct stemmer;
  extern struct stemmer * create_stemmer(void);
  extern void free_stemmer(struct stemmer * z);
  extern int stem(struct stemmer * z, char * b, int k);
}

namespace Preprocessing {
  namespace Text {
    
    class PorterStemmer : public InplaceProcessor {
    public:
      static const uint32_t file_mark = 'port';
      uint32_t mark() { return file_mark; }
      
      struct stemmer *stemm;
      PorterStemmer() : InplaceProcessor() {
        stemm = create_stemmer();
      }
      
      ~PorterStemmer() {
        free_stemmer(stemm);
      }
      
      char *process(char *start, char *end) {
        int length = end - start;
        int new_length = stem(stemm, start, end - start - 1);
        
        for(int i = new_length + 1; i <= length; i++)
          start[i] = 0;
        
        return start + new_length;
      }
    };
    
  }
}

#endif

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
thera-0.0.8 lib/quarry/src/preprocessing/text/inplace_processor/porter_stemmer.h
thera-0.0.7 lib/quarry/src/preprocessing/text/inplace_processor/porter_stemmer.h
thera-0.0.6 lib/quarry/src/preprocessing/text/inplace_processor/porter_stemmer.h
thera-0.0.5 lib/quarry/src/preprocessing/text/inplace_processor/porter_stemmer.h
thera-0.0.4 lib/quarry/src/preprocessing/text/inplace_processor/porter_stemmer.h
thera-0.0.3 lib/quarry/src/preprocessing/text/inplace_processor/porter_stemmer.h
thera-0.0.2 lib/quarry/src/preprocessing/text/inplace_processor/porter_stemmer.h
thera-0.0.1 lib/quarry/src/preprocessing/text/inplace_processor/porter_stemmer.h