INL / corpus-frontend

BlackLab Frontend, a feature-rich corpus search interface for BlackLab.
16 stars 7 forks source link

Feature request: Collocation #473

Open fishfree opened 5 months ago

fishfree commented 5 months ago

Collocation is usually a necessary feature of corpus management system. Maybe I should post in the BlackLab backend repo. Does BlackLab backend provide the correspondent method and HTTP API?

KCMertens commented 5 months ago

BlackLab supports collocation, but we don't show it in the ui (yet): https://inl.github.io/BlackLab/server/rest-api/corpus/hits/get.html#:~:text=specify%20the%20value-,colloc,-to%20calculate%20collocations

If you create the query manually, it should be fairly easy to get collocations in a script. I'll have a look if we can expose this in the interface.

corpusId = 'my_corpus'
fetch(`http://localhost:8080/blacklab-server/${corpusId}/hits?` + new URLSearchParams({
    patt: '"word"',
    calc: 'colloc',
    wordsaroundhit: 10
}).toString(), {
    headers: {
        'Accept': 'application/json' }
    }
)
.then(r => r.json())
.then(console.log)