当前位置: 首页>>代码示例>>C#>>正文


C# VowpalWabbit.HashSpace方法代码示例

本文整理汇总了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);
        }
开发者ID:adgaudio,项目名称:vowpal_wabbit,代码行数:27,代码来源:Namespace.cs

示例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;
        }
开发者ID:XkhldY,项目名称:vowpal_wabbit,代码行数:20,代码来源:Namespace.cs

示例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;
        }
开发者ID:jconwell,项目名称:vowpal_wabbit,代码行数:21,代码来源:Namespace.cs

示例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);
        }
开发者ID:G453,项目名称:vowpal_wabbit,代码行数:28,代码来源:TestManagedHash.cs

示例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);
            }
        }
开发者ID:gramhagen,项目名称:vowpal_wabbit,代码行数:12,代码来源:TestManagedHash.cs

示例6: TestHashSpace

 public void TestHashSpace()
 {
     using (var vw = new VowpalWabbit(""))
     {
         Assert.AreEqual(0ul, vw.HashSpace(" "));
         Assert.AreEqual(0ul, vw.HashSpace("0"));
     }
 }
开发者ID:gramhagen,项目名称:vowpal_wabbit,代码行数:8,代码来源:TestManagedHash.cs


注:本文中的VowpalWabbit.HashSpace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。