コード例 #1
0
ファイル: Collector.cs プロジェクト: gbrian/resin
        private IEnumerable <DocumentScore> DoScore(IList <DocumentPosting> postings, string field)
        {
            if (postings.Any())
            {
                var scorer = _scorer.CreateScorer(_ix.DocumentCount.DocCount[field], postings.Count);

                foreach (var posting in postings)
                {
                    var score = scorer.Score(posting);

                    yield return(score);
                }
            }
        }
コード例 #2
0
ファイル: Collector.cs プロジェクト: CodeFork/resin
        private IEnumerable <DocumentScore> DoScore(IList <DocumentPosting> postings)
        {
            var docHashesFileName = Path.Combine(_directory, string.Format("{0}.{1}", _ix.VersionId, "pk"));

            using (var docHashReader = new DocHashReader(docHashesFileName))
            {
                if (_scorerFactory == null)
                {
                    foreach (var posting in postings)
                    {
                        var docHash = docHashReader.Read(posting.DocumentId);

                        if (!docHash.IsObsolete)
                        {
                            yield return(new DocumentScore(posting.DocumentId, docHash.Hash, 0, _ix));
                        }
                    }
                }
                else
                {
                    if (postings.Any())
                    {
                        var docsWithTerm = postings.Count;

                        var scorer = _scorerFactory.CreateScorer(_documentCount, docsWithTerm);

                        foreach (var posting in postings)
                        {
                            var docHash = docHashReader.Read(posting.DocumentId);

                            if (!docHash.IsObsolete)
                            {
                                var score = scorer.Score(posting);

                                yield return(new DocumentScore(posting.DocumentId, docHash.Hash, score, _ix));
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: Collector.cs プロジェクト: TheBeardedLlama/resin
        private IEnumerable <DocumentScore> GetScoredResult(Term term, IScoringScheme scoringScheme)
        {
            var trie = GetTrie(term.Field);

            if (_ix == null)
            {
                yield break;
            }
            var totalNumOfDocs = _ix.DocCount[term.Field];

            if (trie.ContainsToken(term.Value))
            {
                var termData = GetPostingsFile(term.Field, term.Value);
                var scorer   = scoringScheme.CreateScorer(totalNumOfDocs, termData.Postings.Count);
                foreach (var posting in termData.Postings)
                {
                    var hit = new DocumentScore(posting.Key, posting.Value, totalNumOfDocs);
                    scorer.Score(hit);
                    yield return(hit);
                }
            }
        }
コード例 #4
0
ファイル: Collector.cs プロジェクト: light88/resin
        private IEnumerable <DocumentScore> DoScore(IList <DocumentPosting> postings)
        {
            if (_scorerFactory == null)
            {
                foreach (var posting in postings.OrderBy(p => p.DocumentId))
                {
                    var docHash = _docHashReader.Read(posting.DocumentId);

                    if (!docHash.IsObsolete)
                    {
                        yield return(new DocumentScore(posting.DocumentId, docHash.Hash, 0, _ix));
                    }
                }
            }
            else
            {
                if (postings.Any())
                {
                    var docsWithTerm = postings.Count;

                    var scorer = _scorerFactory.CreateScorer(_documentCount, docsWithTerm);

                    foreach (var posting in postings.OrderBy(p => p.DocumentId))
                    {
                        var docHash = _docHashReader.Read(posting.DocumentId);

                        if (!docHash.IsObsolete)
                        {
                            var score = scorer.Score(posting);

                            yield return(new DocumentScore(posting.DocumentId, docHash.Hash, score, _ix));
                        }
                    }
                }
            }
        }