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


C# IMapping.ToInternalID方法代码示例

本文整理汇总了C#中IMapping.ToInternalID方法的典型用法代码示例。如果您正苦于以下问题:C# IMapping.ToInternalID方法的具体用法?C# IMapping.ToInternalID怎么用?C# IMapping.ToInternalID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMapping的用法示例。


在下文中一共展示了IMapping.ToInternalID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

		/// <summary>Read binary relation data from file</summary>
		/// <remarks>
		/// The expected (sparse) line format is:
		/// ENTITY_ID space/tab/comma ENTITY_ID
		/// for the relations that hold.
		/// </remarks>
		/// <param name="reader">a StreamReader to be read from</param>
		/// <param name="mapping">the mapping object for the given entity type</param>
		/// <returns>the relation data</returns>
		static public IBooleanMatrix Read(StreamReader reader, IMapping mapping)
		{
			var matrix = new SparseBooleanMatrix();

			string line;
			while ((line = reader.ReadLine()) != null)
			{
				// ignore empty lines
				if (line.Length == 0)
					continue;

				string[] tokens = line.Split(Constants.SPLIT_CHARS);

				if (tokens.Length != 2)
					throw new FormatException("Expected exactly 2 columns: " + line);

				int entity1_id = mapping.ToInternalID(tokens[0]);
				int entity2_id = mapping.ToInternalID(tokens[1]);

				matrix[entity1_id, entity2_id] = true;
			}

			return matrix;
		}
开发者ID:WisonHuang,项目名称:MyMediaLite,代码行数:33,代码来源:RelationData.cs

示例2: Read

        /// <summary>Read in implicit feedback data from an IDataReader, e.g. a database via DbDataReader</summary>
        /// <param name="reader">the IDataReader to be read from</param>
        /// <param name="user_mapping">user <see cref="IMapping"/> object</param>
        /// <param name="item_mapping">item <see cref="IMapping"/> object</param>
        /// <returns>a <see cref="IPosOnlyFeedback"/> object with the user-wise collaborative data</returns>
        public static IPosOnlyFeedback Read(IDataReader reader, IMapping user_mapping, IMapping item_mapping)
        {
            var feedback = new PosOnlyFeedback<SparseBooleanMatrix>();

            if (reader.FieldCount < 2)
                throw new FormatException("Expected at least 2 columns.");

            Func<string> get_user_id = reader.GetStringGetter(0);
            Func<string> get_item_id = reader.GetStringGetter(1);

            while (reader.Read())
            {
                int user_id = user_mapping.ToInternalID(get_user_id());
                int item_id = item_mapping.ToInternalID(get_item_id());

                feedback.Add(user_id, item_id);
            }

            return feedback;
        }
开发者ID:zenogantner,项目名称:MyMediaLite,代码行数:25,代码来源:ItemData.cs

示例3: Read

        /// <summary>Read in rating data from an IDataReader, e.g. a database via DbDataReader</summary>
        /// <param name="reader">the <see cref="IDataReader"/> to read from</param>
        /// <param name="user_mapping">mapping object for user IDs</param>
        /// <param name="item_mapping">mapping object for item IDs</param>
        /// <returns>the rating data</returns>
        public static IRatings Read(IDataReader reader, IMapping user_mapping, IMapping item_mapping)
        {
            var ratings = new Ratings();

            if (reader.FieldCount < 3)
                throw new FormatException("Expected at least 3 columns.");

            Func<string> get_user_id = reader.GetStringGetter(0);
            Func<string> get_item_id = reader.GetStringGetter(1);
            Func<float>  get_rating  = reader.GetFloatGetter(2);

            while (reader.Read())
            {
                int user_id = user_mapping.ToInternalID(get_user_id());
                int item_id = item_mapping.ToInternalID(get_item_id());
                float rating = get_rating();

                ratings.Add(user_id, item_id, rating);
            }
            ratings.InitScale();
            return ratings;
        }
开发者ID:pipifuyj,项目名称:MyMediaLite,代码行数:27,代码来源:RatingData.cs

示例4: Read

		/// <summary>Read binary attribute data from an IDataReader, e.g. a database via DbDataReader</summary>
		/// <param name="reader">an IDataReader to be read from</param>
		/// <param name="mapping">the mapping object for the given entity type</param>
		/// <returns>the attribute data</returns>
		static public IBooleanMatrix Read(IDataReader reader, IMapping mapping)
		{
			if (reader.FieldCount < 2)
				throw new Exception("Expected at least 2 columns.");

			var matrix = new SparseBooleanMatrix();

			while (!reader.Read())
			{
				int entity_id = mapping.ToInternalID(reader.GetString(0));
				int attr_id   = reader.GetInt32(1);

				matrix[entity_id, attr_id] = true;
			}

			return matrix;
		}
开发者ID:WisonHuang,项目名称:MyMediaLite,代码行数:21,代码来源:AttributeData.cs


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