// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) by respective owners including Yahoo!, Microsoft, and // individual contributors. All rights reserved. Released under a BSD // license as described in the file LICENSE. // // -------------------------------------------------------------------------------------------------------------------- using System; namespace VW.Serializer { /// /// Constants used throughout C# wrapper. /// public sealed class PropertyConfiguration { /// /// Default value for feature ignore prefix: '_'. /// public const string FeatureIgnorePrefixDefault = "_"; /// /// Default value for text property: '_text'. /// public const string TextPropertyDefault = "_text"; /// /// Default value for label property: '_label'. /// public const string LabelPropertyDefault = "_label"; /// /// Default value for label index property: '_labelindex'. /// public const string LabelIndexPropertyDefault = "_labelindex"; /// /// Default value for label property prefix: '_label_'; /// public const string LabelPropertyPrefixDefault = "_label_"; /// /// Default value for multi property: '_multi'. /// public const string MultiPropertyDefault = "_multi"; /// /// Default singleton holding the default configuration. /// public static readonly PropertyConfiguration Default = new PropertyConfiguration(); /// /// Initializes a new instance. /// public PropertyConfiguration() { this.FeatureIgnorePrefix = FeatureIgnorePrefixDefault; this.TextProperty = TextPropertyDefault; this.LabelProperty = LabelPropertyDefault; this.MultiProperty = MultiPropertyDefault; this.LabelIndexProperty = LabelIndexPropertyDefault; this.LabelPropertyPrefix = LabelPropertyPrefixDefault; } /// /// JSON properties starting with underscore are ignored. /// public string FeatureIgnorePrefix { get; set; } /// /// JSON property "_text" is marshalled using . /// public string TextProperty { get; set; } /// /// JSON property "_label" is used as label. /// public string LabelProperty { get; set; } /// /// JSON property "_labelIndex" determines the index this label is applied for multi-line examples. /// public string LabelIndexProperty { get; set; } /// /// JSON properties starting with "_label_$name" are used to specify nested properties. Has the same effect as _label: { "$name": ... }. /// public string LabelPropertyPrefix { get; set; } /// /// JSON property "_multi" is used to signal multi-line examples. /// public string MultiProperty { get; set; } /// /// True if is considered a special property and thus should not be skipped. /// /// The JSON property name. /// True if is a special property, false otherwise. public bool IsSpecialProperty(string property) { return property.Equals(TextProperty, StringComparison.OrdinalIgnoreCase) || property.Equals(LabelProperty, StringComparison.OrdinalIgnoreCase) || property.Equals(MultiProperty, StringComparison.OrdinalIgnoreCase) || property.Equals(LabelIndexProperty, StringComparison.OrdinalIgnoreCase) || property.StartsWith(LabelPropertyPrefixDefault, StringComparison.OrdinalIgnoreCase); } } }