Skip to content

Commit

Permalink
Add meta example features-char-string
Browse files Browse the repository at this point in the history
  • Loading branch information
avramidis committed Dec 13, 2018
1 parent d751f66 commit be01de6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/meta/generator/targets/cpp.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"Type": {
"RealFeatures": "DenseFeatures<float64_t>",
"RealSubsetFeatures": "DenseSubsetFeatures<float64_t>",
"StringCharFeatures": "CStringFeatures<char>",
"StringCharFeatures": "StringFeatures<char>",
"Default": "$typeName",
"bool": "bool",
"string": "char*",
Expand Down
10 changes: 10 additions & 0 deletions examples/meta/src/features/string_char.sg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
File words = csv_file("../../data/words.dat")

#![create_features]
Features f = string_features(words, enum EAlphabet.RAWBYTE)
#![create_features]

#![output stat]
int max_string_length = f.get_int("max_string_length")
int number_of_strings = f.get_num_vectors()
#![output stat]
1 change: 1 addition & 0 deletions src/shogun/features/StringFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <shogun/features/Features.h>
#include <shogun/features/Alphabet.h>
#include <shogun/lib/SGString.h>
#include <shogun/lib/SGStringList.h>

namespace shogun
{
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/util/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ namespace shogun
}

CFeatures* string_features(
CFile* file, EAlphabet alpha = DNA,
EPrimitiveType primitive_type = PT_CHAR)
CFile* file, machine_int_t alphabet_type = DNA,
machine_int_t primitive_type = PT_CHAR)
{
REQUIRE(file, "No file provided.\n");
CFeatures* result = nullptr;

switch (primitive_type)
{
case PT_CHAR:
result = new CStringFeatures<char>(file, alpha);
result = new CStringFeatures<char>(file, static_cast<EAlphabet>(alphabet_type));
break;
default:
SG_SNOTIMPLEMENTED
Expand Down

0 comments on commit be01de6

Please sign in to comment.