本文整理汇总了C#中VowpalWabbit.HashSpace方法的典型用法代码示例。如果您正苦于以下问题:C# VowpalWabbit.HashSpace方法的具体用法?C# VowpalWabbit.HashSpace怎么用?C# VowpalWabbit.HashSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VowpalWabbit
的用法示例。
在下文中一共展示了VowpalWabbit.HashSpace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Namespace
/// <summary>
/// Initializes a new namespace instance.
/// </summary>
/// <param name="vw">VopwpalWabbit instance used for hashing.</param>
/// <param name="name">The namespace name.</param>
/// <param name="featureGroup">Defaults to space, if null.</param>
public Namespace(VowpalWabbit vw, string name, char? featureGroup)
{
this.Name = name;
this.FeatureGroup = featureGroup ?? ' ';
if (featureGroup == null && !string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException("If Namespace is provided, FeatureGroup must be set too");
}
// compute shared namespace hash
this.NamespaceHash = name == null ?
vw.HashSpace(this.FeatureGroup.ToString()) :
vw.HashSpace(this.FeatureGroup + this.Name);
this.NamespaceString = string.Format(
CultureInfo.InvariantCulture,
" |{0}{1}",
this.FeatureGroup,
this.Name);
}
示例2: Namespace
/// <summary>
/// Initializes a new <see cref="Namespace"/> instance.
/// </summary>
/// <param name="vw">VopwpalWabbit instance used for hashing.</param>
/// <param name="name">The namespace name. First character is treated as feature group. Defaults to space.</param>
public Namespace(VowpalWabbit vw, string name = null)
{
if (string.IsNullOrWhiteSpace(name))
name = VowpalWabbitConstants.DefaultNamespace.ToString();
if (name.Length > 1)
this.Name = name.Substring(1);
this.FeatureGroup = name[0];
this.NamespaceHash = vw.HashSpace(name);
if (vw.Settings.EnableStringExampleGeneration)
this.NamespaceString = " |" + name;
}
示例3: Namespace
/// <summary>
/// Initializes a new <see cref="Namespace"/> instance.
/// </summary>
/// <param name="vw">VopwpalWabbit instance used for hashing.</param>
/// <param name="name">The namespace name. First character is treated as feature group. Defaults to space.</param>
public Namespace(VowpalWabbit vw, string name = null)
{
if (string.IsNullOrWhiteSpace(name))
{
name = " ";
}
if (name.Length > 1)
{
this.Name = name.Substring(1);
}
this.FeatureGroup = name[0];
this.NamespaceHash = vw.HashSpace(name);
this.NamespaceString = " |" + name;
}
示例4: InternalTestHash
private void InternalTestHash(string args)
{
var stopWatchNative = new Stopwatch();
var stopWatchManaged = new Stopwatch();
using (var vw = new VowpalWabbit(args))
{
for (int i = 0; i < 10000; i++)
{
foreach (var item in data)
{
stopWatchNative.Start();
var nativeHash = vw.HashSpaceNative(item);
stopWatchNative.Stop();
stopWatchManaged.Start();
var managedHash = vw.HashSpace(item);
stopWatchManaged.Stop();
Assert.AreEqual(nativeHash, managedHash, item);
}
}
}
Console.WriteLine("Args: " + args);
Console.WriteLine("native: {0}", stopWatchNative.Elapsed);
Console.WriteLine("managed: {0}", stopWatchManaged.Elapsed);
}
示例5: TestHashUnicodeSpace
public void TestHashUnicodeSpace()
{
using (var vw = new VowpalWabbit(""))
{
var value = "ArticleTitleThe_25_Biggest_Art_Moments_of_2012" + (char)160;
// Encoding.UTF8.GetMaxByteCount
var nativeHash = vw.HashSpaceNative(value);
var managedHash = vw.HashSpace(value);
Assert.AreEqual(nativeHash, managedHash);
}
}
示例6: TestHashSpace
public void TestHashSpace()
{
using (var vw = new VowpalWabbit(""))
{
Assert.AreEqual(0ul, vw.HashSpace(" "));
Assert.AreEqual(0ul, vw.HashSpace("0"));
}
}