public JobAdHighlighter(LuceneQuery contentQuery, LuceneQuery titleQuery, LuceneQuery advertiserQuery, Analyzer contentAnalyzer, HighlighterConfiguration configuration) : base(contentAnalyzer, configuration) { _contentQuery = contentQuery; _titleQuery = titleQuery; _advertiserQuery = advertiserQuery; }
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; }
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)); }
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); } }
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); } }
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)); } }
internal SeniorityIndexQuery(LuceneQuery subQuery, ValueSourceQuery valueSourceQuery, int seniorityIndex, float sigma) : base(subQuery, valueSourceQuery) { _seniorityIndex = seniorityIndex; _sigma = sigma; }
public FaqHighlighter(LuceneQuery contentQuery, Analyzer contentAnalyzer, HighlighterConfiguration configuration) : base(contentAnalyzer, configuration) { _contentQuery = contentQuery; }
LuceneQuery IMemberSearchBooster.GetJobTitleBoostingQuery(LuceneQuery query, LuceneQuery jobTitleQuery) { return(GetBoostingQuery(query, jobTitleQuery, JobTitleBoost)); }
LuceneQuery IMemberSearchBooster.GetRecencyBoostingQuery(LuceneQuery query) { return(GetRecencyBoostingQuery(query, FieldName.LastUpdatedDay, TimeGranularity.Day, RecencyAlpha, RecencyHalfDecay)); }
LuceneQuery IJobAdSearchBooster.GetRecencyBoostingQuery(LuceneQuery query) { return(GetRecencyBoostingQuery(query, FieldName.CreatedTime, TimeGranularity.Hour, RecencyAlpha, RecencyHalfDecay)); }