Пример #1
0
 public JobAdHighlighter(LuceneQuery contentQuery, LuceneQuery titleQuery, LuceneQuery advertiserQuery, Analyzer contentAnalyzer, HighlighterConfiguration configuration)
     : base(contentAnalyzer, configuration)
 {
     _contentQuery    = contentQuery;
     _titleQuery      = titleQuery;
     _advertiserQuery = advertiserQuery;
 }
Пример #2
0
 public ResumeHighlighter(LuceneQuery contentQuery, LuceneQuery jobTitleQuery, LuceneQuery desiredJobTitleQuery, LuceneQuery employerQuery, LuceneQuery educationQuery, Analyzer contentAnalyzer, HighlighterConfiguration configuration)
     : base(contentAnalyzer, configuration)
 {
     _contentQuery         = contentQuery;
     _jobTitleQuery        = jobTitleQuery;
     _desiredJobTitleQuery = desiredJobTitleQuery;
     _employerQuery        = employerQuery;
     _educationQuery       = educationQuery;
 }
Пример #3
0
        protected LuceneQuery GetQuery(LuceneQuery contentQuery, int?seniorityIndex, float sigma)
        {
            if (!seniorityIndex.HasValue)
            {
                return(contentQuery);
            }

            var seniorityQuery = new ValueSourceQuery(new IntFieldSource(_fieldName));

            return(new SeniorityIndexQuery(contentQuery, seniorityQuery, seniorityIndex.Value, sigma));
        }
Пример #4
0
        protected string Highlight(LuceneQuery query, string text, bool htmlEncodeOutput)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            try
            {
                Encoder encoder;

                if (htmlEncodeOutput)
                {
                    encoder = new SimpleHTMLEncoder();
                }
                else
                {
                    encoder = new DefaultEncoder();
                }

                if (query == null)
                {
                    return(encoder.encodeText(text)); // nothing to highlight
                }
                // Build the highlighter.

                var formatter   = new SimpleHTMLFormatter(_configuration.StartTag, _configuration.EndTag);
                var highlighter = new LuceneHighlighter(formatter, encoder, new QueryScorer(query));
                highlighter.setTextFragmenter(new NullFragmenter());

                // Perform highlighting.

                var highlightedHtml = highlighter.getBestFragment(_contentAnalyzer, string.Empty, text);
                return(highlightedHtml ?? encoder.encodeText(text));
            }
            catch (Exception)
            {
                // on error just return the original string
                return(text);
            }
        }
Пример #5
0
        protected string Summarize(LuceneQuery query, string text, bool htmlEncodeOutput)
        {
            if (query == null || string.IsNullOrEmpty(text))
            {
                return(null);
            }

            try
            {
                // Build the highlighter.

                var formatter = new SimpleHTMLFormatter(_configuration.StartTag, _configuration.EndTag);
                var scorer    = new QueryScorer(query);

                Encoder encoder;

                if (htmlEncodeOutput)
                {
                    encoder = new SimpleHTMLEncoder();
                }
                else
                {
                    encoder = new DefaultEncoder();
                }

                var highlighter = new LuceneHighlighter(formatter, encoder, scorer);
                highlighter.setTextFragmenter(new SimpleSpanFragmenter(scorer, _configuration.FragmentSize));

                // Perform highlighting.

                var tokenStream = _contentAnalyzer.tokenStream(string.Empty, new java.io.StringReader(text));
                return(highlighter.getBestFragments(tokenStream, text, _configuration.MaxFragments, _configuration.Separator));
            }
            catch (Exception)
            {
                // on error just return the original string
                return(text);
            }
        }
Пример #6
0
        private void AddSection(ICollection <KeyValuePair <string, string> > summaries, LuceneQuery query, string sectionName, string sectionText)
        {
            var sectionSummary = Summarize(query, sectionText, true);

            if (!string.IsNullOrEmpty(sectionSummary))
            {
                summaries.Add(new KeyValuePair <string, string>(sectionName, sectionSummary));
            }
        }
Пример #7
0
 internal SeniorityIndexQuery(LuceneQuery subQuery, ValueSourceQuery valueSourceQuery, int seniorityIndex, float sigma)
     : base(subQuery, valueSourceQuery)
 {
     _seniorityIndex = seniorityIndex;
     _sigma          = sigma;
 }
Пример #8
0
 public FaqHighlighter(LuceneQuery contentQuery, Analyzer contentAnalyzer, HighlighterConfiguration configuration)
     : base(contentAnalyzer, configuration)
 {
     _contentQuery = contentQuery;
 }
Пример #9
0
 LuceneQuery IMemberSearchBooster.GetJobTitleBoostingQuery(LuceneQuery query, LuceneQuery jobTitleQuery)
 {
     return(GetBoostingQuery(query, jobTitleQuery, JobTitleBoost));
 }
Пример #10
0
 LuceneQuery IMemberSearchBooster.GetRecencyBoostingQuery(LuceneQuery query)
 {
     return(GetRecencyBoostingQuery(query, FieldName.LastUpdatedDay, TimeGranularity.Day, RecencyAlpha, RecencyHalfDecay));
 }
Пример #11
0
 LuceneQuery IJobAdSearchBooster.GetRecencyBoostingQuery(LuceneQuery query)
 {
     return(GetRecencyBoostingQuery(query, FieldName.CreatedTime, TimeGranularity.Hour, RecencyAlpha, RecencyHalfDecay));
 }