Reduce resource waste (#128)

This commit is contained in:
Viktor Lofgren 2022-11-18 17:13:08 +01:00
parent 674af5449d
commit f0f82f7db0
3 changed files with 12 additions and 16 deletions

View File

@ -26,13 +26,13 @@ once per 6-8 weeks, coinciding with the crawling
cycle. Where model-breaking changes and changes to
the crawler can be introduced.
## Quick Set Up
## Running and set-up
There is a [Set Up Guide](https://git.marginalia.nu/marginalia/marginalia.nu/wiki/Setup/Search)
in the wiki. It has a small tendency to oxidize rather
rapidly since the project currently does not have a
lot of contributors to test it. If you find a problem
with the guide, email <kontakt@marginalia.nu>.
There is a complementary project, wmsa.local, which
contains scripts and instructions for running this
code base.
[https://git.marginalia.nu/marginalia/wmsa.local](https://git.marginalia.nu/marginalia/wmsa.local)
## Documentation

View File

@ -23,7 +23,7 @@ Documentation is a work in progress. See the [wiki](https://git.marginalia.nu/ma
## Contributing
The project is still being set up, but if you are interested in contributing, please contact me.
[CONTRIBUTING.md](CONTRIBUTING.md)
## Supporting

View File

@ -23,15 +23,13 @@ import java.util.*;
@Singleton
public class QueryFactory {
private final LanguageModels lm;
private final TermFrequencyDict dict;
private final EnglishDictionary englishDictionary;
private final NGramBloomFilter nGramBloomFilter;
private final Logger logger = LoggerFactory.getLogger(getClass());
private final SearchResultValuator searchResultValuator;
private NearQueryProcessor nearQueryProcessor;
private final NearQueryProcessor nearQueryProcessor;
private static final int RETAIN_QUERY_VARIANT_COUNT = 5;
private final ThreadLocal<QueryVariants> queryVariants;
@Inject
public QueryFactory(LanguageModels lm,
@ -40,17 +38,16 @@ public class QueryFactory {
NGramBloomFilter nGramBloomFilter,
SearchResultValuator searchResultValuator,
NearQueryProcessor nearQueryProcessor) {
this.lm = lm;
this.dict = dict;
this.englishDictionary = englishDictionary;
this.nGramBloomFilter = nGramBloomFilter;
this.searchResultValuator = searchResultValuator;
this.nearQueryProcessor = nearQueryProcessor;
this.queryVariants = ThreadLocal.withInitial(() -> new QueryVariants(lm, dict, nGramBloomFilter, englishDictionary));
}
public QueryParser getParser() {
return new QueryParser(englishDictionary, new QueryVariants(lm ,dict, nGramBloomFilter, englishDictionary));
return new QueryParser(englishDictionary, queryVariants.get());
}
public EdgeSearchQuery createQuery(EdgeUserSearchParameters params) {
@ -219,7 +216,6 @@ public class QueryFactory {
EdgeSearchSpecification specs = specsBuilder.build();
return new EdgeSearchQuery(specs, searchTermsHuman, domain);
}
private String normalizeDomainName(String str) {