scorer.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Tencent is pleased to support the open source community by making wwsearch
  3. * available.
  4. *
  5. * Copyright (C) 2018-present Tencent. All Rights Reserved.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  8. * use this file except in compliance with the License. You may obtain a copy of
  9. * the License at
  10. *
  11. * https://opensource.org/licenses/Apache-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OF ANY KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations under the License.
  17. */
  18. #pragma once
  19. #include "doc_iterator.h"
  20. #include "storage_type.h"
  21. #include "weight.h"
  22. namespace wwsearch {
  23. class Weight;
  24. /* Notice : The interface is used to get DocID list.
  25. * Input : Weight
  26. * Output : Doc id list
  27. * Getting doc id list by calling weight.
  28. * This `Scorer` class supports extending to score the doc id output or not.
  29. */
  30. class Scorer {
  31. private:
  32. Weight *weight_;
  33. std::string scorer_name_;
  34. public:
  35. Scorer(Weight *weight, const std::string &scorer_name)
  36. : weight_(weight), scorer_name_(scorer_name) {}
  37. virtual ~Scorer() {}
  38. virtual DocumentID DocID() = 0;
  39. virtual double Score() = 0;
  40. inline const std::string &Name() const { return scorer_name_; }
  41. virtual DocIdSetIterator &Iterator() = 0;
  42. inline Weight *GetWeight() { return this->weight_; }
  43. private:
  44. };
  45. class BulkScorer {
  46. private:
  47. public:
  48. virtual ~BulkScorer() {}
  49. private:
  50. };
  51. } // namespace wwsearch