コード例 #1
0
        /// <summary>
        /// Checks if the term entry contains given posting, ie. if the term is in the given artifact.
        /// </summary>
        /// <param name="artifactId">artifact id</param>
        /// <returns>true, if termEntry conatins the posting, false otherwise</returns>
        /// <exception cref="System.ArgumentException">if artifact id is null or empty</exception>
        public bool ContainsPosting(string artifactId)
        {
            if (artifactId == null || artifactId == "")
            {
                throw new ArgumentException("The documentId cannot be empty or null");
            }

            return(PostingsLookup.ContainsKey(artifactId));
        }
コード例 #2
0
        /// <summary>
        /// Allows adding new posting to the termEntry.
        /// </summary>
        /// <exception cref="System.ArgumentException">if posting is null</exception>
        private void AddPosting(TLPosting posting)
        {
            if (posting == null)
            {
                throw new ArgumentException("The posting cannot be null");
            }

            PostingsLookup.Add(posting.ArtifactId, posting);
            m_postings.Add(posting);
        }
コード例 #3
0
        /// <summary>
        /// Gets the posting for the specified artifact id
        /// </summary>
        /// <param name="artifactId">artifact id</param>
        /// <returns>the posting for the specified artifact</returns>
        /// <exception cref="System.ArgumentException">if artifact id is null or empty</exception>
        public TLPosting GetPosting(string artifactId)
        {
            if (artifactId == null || artifactId == "")
            {
                throw new ArgumentException("The documentId cannot be empty or null");
            }

            TLPosting posting;

            if (!PostingsLookup.TryGetValue(artifactId, out posting))
            {
                throw new ArgumentException("Postings collection does not contain specified document");
            }
            else
            {
                return(posting);
            }
        }
コード例 #4
0
        /// <summary>
        /// Allows adding new posting to the termEntry.
        /// </summary>
        /// <param name="artifactId">artifact id</param>
        /// <param name="frequency">frequency of the term in the given artifact</param>
        /// <param name="weight">local weight of the term in the posting</param>
        /// <returns>created posting</returns>
        /// <exception cref="System.ArgumentException">if documentId is null or empty; or if frequency is less than 0</exception>
        public TLPosting AddPosting(string artifactId, int frequency, double weight)
        {
            if (artifactId == null || artifactId == "")
            {
                throw new ArgumentException("The documentId cannot be empty or null");
            }
            if (frequency <= 0)
            {
                throw new ArgumentException("Frequency has to be greater than 0.");
            }

            TLPosting posting = new TLPosting(artifactId, frequency, weight);

            PostingsLookup.Add(artifactId, posting);
            m_postings.Add(posting);

            return(posting);
        }