Grew-count web service

The Grew-count web service is available on https://count.grew.fr.

With the Grew-count web service, it is possible to send a list of Grew requests and a list of corpora and to get a TSV file with the number of occurrences of each request in each corpus. Corpora available are ones which are used in Grew-match.

Note that if you want to run similar requests on your onw data, you should consider using the grewpy library: see an example here.


The count service

The URL of the main service is https://count.grew.fr/count and it must be called with two POST parameters: corpora and requests.

The corpora parameter must be a JSON string describing a list of corpora. For instance:

[
  "SUD_French-PUD@2.15",
  "SUD_English-PUD@2.15"
]

The available corpora are the same as the ones available on Grew-match, with the same identifiers.

The requests parameter must be a JSON string describing a dictionary of requests. For instance:

{
  "sv": "pattern { V -[subj]-> S; S << V }",
  "vs": "pattern { V -[subj]-> S; V << S }"
}

Again, the requests are the same as the ones available on Grew-match. requests syntax can be learned through Grew-match’s tutorial and some documentation is available on the request page.


The set_config service

If you want to run requests on UD or SUD data, you should first run the service. For instance from Python:

# Set the config to "UD"
url = "https://count.grew.fr/count"
requests.request("POST", f'{url}/set_config', data={'config': 'ud'})

Example of usage with Python

The web service can be called with Python’s requests library. The code below (Download) shows a way to call the web service with the two requests above and with the 20 PUD corpora of SUD 2.14.

import requests

url = "https://count.grew.fr/count"

data={
'corpora': '''[
  "SUD_Arabic-PUD@2.15",
  "SUD_Chinese-PUD@2.15",
  "SUD_Czech-PUD@2.15",
  "SUD_English-PUD@2.15",
  "SUD_Finnish-PUD@2.15",
  "SUD_French-PUD@2.15",
  "SUD_German-PUD@2.15",
  "SUD_Hindi-PUD@2.15",
  "SUD_Icelandic-PUD@2.15",
  "SUD_Indonesian-PUD@2.15",
  "SUD_Italian-PUD@2.15",
  "SUD_Japanese-PUD@2.15",
  "SUD_Korean-PUD@2.15",
  "SUD_Polish-PUD@2.15",
  "SUD_Portuguese-PUD@2.15",
  "SUD_Russian-PUD@2.15",
  "SUD_Spanish-PUD@2.15",
  "SUD_Swedish-PUD@2.15",
  "SUD_Thai-PUD@2.15",
  "SUD_Turkish-PUD@2.15"
]
''',
'requests': '''{
  "sv": "pattern { V -[subj]-> S; S << V }",
  "vs": "pattern { V -[subj]-> S; V << S }"
}
'''}

# Set the config to "SUD"
requests.request("POST", f'{url}/set_config', data={'config': 'sud'})

response = requests.request("POST", url, data=data)
print(response.text, end="") # The `response.text` already contains a newline

The script should produce, the following TSV file:

Corpus	# sentences	sv	vs
SUD_Arabic-PUD@2.15	1000	486	941
SUD_Chinese-PUD@2.15	1000	1833	11
SUD_Czech-PUD@2.15	1000	926	376
SUD_English-PUD@2.15	1000	1343	76
SUD_Finnish-PUD@2.15	1000	1013	93
SUD_French-PUD@2.15	1000	1358	60
SUD_German-PUD@2.15	1000	1124	386
SUD_Hindi-PUD@2.15	1000	1124	3
SUD_Icelandic-PUD@2.15	1000	1404	434
SUD_Indonesian-PUD@2.15	1000	1424	129
SUD_Italian-PUD@2.15	1000	1024	136
SUD_Japanese-PUD@2.15	1000	1525	0
SUD_Korean-PUD@2.15	1000	1564	1
SUD_Polish-PUD@2.15	1000	856	212
SUD_Portuguese-PUD@2.15	1000	1210	104
SUD_Russian-PUD@2.15	1000	1155	254
SUD_Spanish-PUD@2.15	1000	1077	154
SUD_Swedish-PUD@2.15	1000	1164	384
SUD_Thai-PUD@2.15	1000	1658	10
SUD_Turkish-PUD@2.15	1000	1325	6