CQP and CL interfaces for Python
Project description
This is a Python wrapper to the low-level API of CQP which allows
you to access CQP corpora in the same way as Perl's CWB::CL
To install the module, please use the standard
python setup.py build
sudo python setup.py install
command sequence.
If you use the newest version of CQP (CWB 3.0), you need to
change the value of the "extra_libs" variable in setup.py.
To give you an idea how this works, see the following sample:
--- 8< ---
from CWB.CL import Corpus
# open the corpus
corpus=Corpus('TUEPP')
# get sentences and words
sentences=corpus.attribute('s','s')
words=corpus.attribute('word','p')
postags=corpus.attribute('pos','p')
# retrieve offsets of the 1235th sentence (0-based)
s_1234=sentences[1234]
for w,p in zip(words[s_1234[0]:s_1234[1]+1],postags[s_1234[0]:s_1234[1]+1]):
print "%s/%s"%(w,p)
--- 8< ---
In order to test the CWB.CL module's correct installation
independently of any CQP corpora, you can do a
python -m doctest tests/idlist.txt
which should terminate with no output when everything is well.
you to access CQP corpora in the same way as Perl's CWB::CL
To install the module, please use the standard
python setup.py build
sudo python setup.py install
command sequence.
If you use the newest version of CQP (CWB 3.0), you need to
change the value of the "extra_libs" variable in setup.py.
To give you an idea how this works, see the following sample:
--- 8< ---
from CWB.CL import Corpus
# open the corpus
corpus=Corpus('TUEPP')
# get sentences and words
sentences=corpus.attribute('s','s')
words=corpus.attribute('word','p')
postags=corpus.attribute('pos','p')
# retrieve offsets of the 1235th sentence (0-based)
s_1234=sentences[1234]
for w,p in zip(words[s_1234[0]:s_1234[1]+1],postags[s_1234[0]:s_1234[1]+1]):
print "%s/%s"%(w,p)
--- 8< ---
In order to test the CWB.CL module's correct installation
independently of any CQP corpora, you can do a
python -m doctest tests/idlist.txt
which should terminate with no output when everything is well.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cwb-python-0.1a.tar.gz
(47.6 kB
view hashes)
Built Distribution
cwb-python-0.1a.linux-x86_64.tar.gz
(163.4 kB
view hashes)
Close
Hashes for cwb-python-0.1a.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ea16a17f661df2bbcadbe6fcb125314680b86519a0fd0f9d46e537fb3807233 |
|
MD5 | c6c65e1222b38cccd51a8212d09e5f38 |
|
BLAKE2b-256 | 0bcacfc4fe0cd3b8530d88d984bce94952dfe84eff3dec1e1b3956fed564c776 |