/*
Copyright (c) by respective owners including Yahoo!, Microsoft, and
individual contributors. All rights reserved. Released under a BSD (revised)
license as described in the file LICENSE.
*/
#pragma once
#include "vw_clr.h"
#include "vw_base.h"
#include "vw_example.h"
#include "vowpalwabbit.h"
#include "vw_label.h"
namespace VW
{
using namespace VW::Labels;
///
/// Helper class to ease construction of native vowpal wabbit namespace data structure.
///
public ref class VowpalWabbitNamespaceBuilder sealed
{
private:
///
/// Features.
///
features* m_features;
///
/// The namespace index.
///
unsigned char m_index;
///
/// The native example.
///
example* m_example;
// float(*m_sum_of_squares)(float*, float*);
!VowpalWabbitNamespaceBuilder();
internal:
///
/// Initializes a new instance.
///
/// Pointer into features owned by .
/// The namespace index.
/// The native example to build up.
VowpalWabbitNamespaceBuilder(features* features, unsigned char index, example* example);
public:
~VowpalWabbitNamespaceBuilder();
///
/// Add feature entry.
///
/// The weight index.
/// The value.
void AddFeature(uint64_t weight_index, float x);
///
/// Adds a dense array to the example.
///
/// The base weight index. Each element is then placed relative to this index.
/// The start pointer of the float array.
/// The end pointer of the float array.
void AddFeaturesUnchecked(uint64_t weight_index_base, float* begin, float* end);
///
/// Pre-allocate features of .
///
/// The number of features to pre-allocate.
void PreAllocate(int size);
property size_t FeatureCount { size_t get(); }
};
///
/// Helper class to ease construction of native vowpal wabbit example data structure.
///
public ref class VowpalWabbitExampleBuilder sealed
{
private:
IVowpalWabbitExamplePool^ m_vw;
///
/// The produced CLR example data structure.
///
VowpalWabbitExample^ m_example;
protected:
///
/// Cleanup.
///
!VowpalWabbitExampleBuilder();
public:
///
/// Initializes a new instance.
///
/// The parent vowpal wabbit instance.
VowpalWabbitExampleBuilder(IVowpalWabbitExamplePool^ vw);
///
/// Cleanup.
///
~VowpalWabbitExampleBuilder();
///
/// Creates the managed example representation.
///
/// Creates the managed example.
VowpalWabbitExample^ CreateExample();
///
/// Sets the label for the resulting example.
///
void ApplyLabel(ILabel^ label);
///
/// Creates and adds a new namespace to this example.
///
VowpalWabbitNamespaceBuilder^ AddNamespace(Byte featureGroup);
///
/// Creates and adds a new namespace to this example.
///
/// The feature group of the new namespace.
/// Casts to System::Byte.
VowpalWabbitNamespaceBuilder^ AddNamespace(Char featureGroup);
};
}