Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query construction #91

Merged
merged 4 commits into from
May 8, 2020
Merged

Query construction #91

merged 4 commits into from
May 8, 2020

Conversation

chriskamphuis
Copy link
Collaborator

Make it possible to construct queries in Pyserini

@chriskamphuis chriskamphuis requested a review from lintool May 8, 2020 18:15


def get_boolean_query_builder():
""" Get a BooleanQueryBuilder object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space here, per PEP 8. and below.



def get_clause_should():
""" Get a BooleanClause.Occur.SHOULD statement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8 - docstring comments should end in periods.

@@ -72,14 +72,14 @@ class SimpleSearcher:
def __init__(self, index_dir: str):
self.object = JSimpleSearcher(JString(index_dir))

def search(self, q: str, k: int=10, t: int=-1,
def search(self, q, k: int=10, t: int=-1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can still provide a type hint here? using Union?

return JQueryGeneratorUtils.getBooleanClauseShould()


def get_clause_must():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to implement an Enum for these? Like here? https://github.com/castorini/pyserini/blob/master/pyserini/pyclass.py#L103

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. Wait, or maybe somehow bind them to singleton symbols?

Dunno...

hits1 = self.searcher.search(bq1)
hits2 = self.searcher.search('information retrieval')

self.assertEqual(hits1[0].docid, hits2[0].docid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you iterate through all the hits to check all scores and docids?

self.assertEqual(hits1[0].docid, hits2[0].docid)
self.assertEqual(hits1[0].score, hits2[0].score)

boost3 = pyquerybuilder.get_boost_query(term_query1, 2.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a test case where you assign both weight 2 - docid (in entire hits) should be the same, but scores different?

@chriskamphuis chriskamphuis requested a review from lintool May 8, 2020 19:46
Copy link
Member

@lintool lintool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think this is a lot cleaner!

@chriskamphuis chriskamphuis merged commit 45cc587 into castorini:master May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants