Git Product home page Git Product logo

Comments (10)

chriskamphuis avatar chriskamphuis commented on July 28, 2024 2

you can just do:

get_term_counts(self, term: str, analyzer=get_lucene_analyzer()) -> Tuple[int, int]: 
    if analyzer is None:
        # skip analysis (pass dummy to Anserini)
    else:
       # perform analysis with analyzer (either default or custom)
    ...

where you import that function from pyanalysis

from pyserini.

PepijnBoers avatar PepijnBoers commented on July 28, 2024

Both taking an analyzer makes sense to me, especially since the getPostingsListWithAnalyzer method is already available in Anserini.

from pyserini.

lintool avatar lintool commented on July 28, 2024

@PepijnBoers do you have cycles to take this on?

from pyserini.

PepijnBoers avatar PepijnBoers commented on July 28, 2024

@lintool sure!

from pyserini.

PepijnBoers avatar PepijnBoers commented on July 28, 2024

Currently get_term_counts applies Anserini's default Lucene analyzer if no analyzer is specified (analyzer=None), then in order to skip term analysis you have to pass a dummy analyzer. Is this the requested behavior or do we want analyzer=None to mean that no analysis should take place?

from pyserini.

lintool avatar lintool commented on July 28, 2024

I'm thinking:

  • No analyzer specified - use default.
  • analyzer=foo - use foo as analyzer
  • analyzer=None - skip analysis

And we make this behavior across all methods (existing, and in the future).

Thoughts?

from pyserini.

PepijnBoers avatar PepijnBoers commented on July 28, 2024

I assumed that None would be the value for an unspecified analyzer, do you suggest we overload the methods in Pyserini and remove a default value for the analyzer parameter?

from pyserini.

PepijnBoers avatar PepijnBoers commented on July 28, 2024

We could do it like this:

get_term_counts(self, term: str, analyzer='unspecified') -> Tuple[int, int]: 
    if analyzer is 'unspecified'":
        # use default
    elif analyzer is None:
        # skip analysis (pass dummy to Anserini)
    else:
       # perform analysis with given analyzer
    ...

from pyserini.

lintool avatar lintool commented on July 28, 2024

What about something simpler, like this?

get_term_counts(self, term: str, analyzer=default) -> Tuple[int, int]: 
    if analyzer is None:
        # skip analysis (pass dummy to Anserini)
    else:
       # perform analysis with analyzer (either default or custom)
    ...

from pyserini.

PepijnBoers avatar PepijnBoers commented on July 28, 2024

Looks good, but then we have to specify default somewhere, otherwise we face a NameError. The question would then also be how/where to define default, right?

from pyserini.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.