From 42121f30050daa4f57e29ffb7bb3231b80c1c4e8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Janz <arkadiusz.janz@pwr.edu.pl> Date: Fri, 12 Jan 2024 21:27:37 +0100 Subject: [PATCH] readme updated --- README.md | 113 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index ee8abdb..9fc190b 100644 --- a/README.md +++ b/README.md @@ -25,51 +25,100 @@ Usage Access is provided using a PLWordNet object, with data loaded from the database dump. To get thethe database dump use the `download` method (see ,,Setup'' section). - >>> import plwn - >>> wn = plwn.load("./default_model") +```python +import plwn + +wn = plwn.load("./default_model") +``` Using that object, it's possible to obtain synset and lexical unit data. - >>> lex = wn.lexical_unit('pies', plwn.PoS.noun_pl, 2) - >>> print(lex) - pies.2(21:zw) - >>> print(lex.definition) - pies domowy - popularne zwierzę domowe, przyjaciel człowieka. +```python + +lex = wn.lexical_unit('pies', plwn.PoS.noun_pl, 2) + +print(lex) +>>> pies.2(21:zw) + +print(lex.definition) +>>>pies domowy - popularne zwierzę domowe, przyjaciel człowieka. + +``` + +Getting synsets, lexical units, and relations: + +1. All synsets + +```python +synsets = wn.synsets() + +synset = synsets[0] +synset.id +``` + +2. All lexical units + +```python +units = wn.lexical_units() + +unit = units[0] +unit.id +unit.lemma +unit.pos +unit.variant +unit.definition +``` + +3. Relations +```python +synset.relations() +unit.relations() +``` Full documentation ================== For description of loading plWordNet data: - $ pydoc plwn._loading +```bash +pydoc plwn._loading +``` For description of the PLWordNet class and others: - $ pydoc plwn.bases +```bash +pydoc plwn.bases +``` -Creating API dumps from wordnet sql +Creating sqlite API dumps from wordnet database sql dump =================================== Latest wordnet database dump can be obtained from http://ws.clarin-pl.eu/public/wordnet-work.LATEST.sql.gz - $ wget http://ws.clarin-pl.eu/public/wordnet-work.LATEST.sql.gz +```bash +wget http://ws.clarin-pl.eu/public/wordnet-work.LATEST.sql.gz +``` This step requires access to mysql server or installed locally. It can be loaded using shell command: - $ mysql -e 'CREATE SCHEMA wordnet_new' # For maintaining multiple versions. - $ atool -x wordnet-work.LATEST.sql.gz # Unpack dump - $ mysql -D wordnet_new < wordnet-work.LATEST.sql +```bash +mysql -e 'CREATE SCHEMA wordnet_new' # For maintaining multiple versions. +atool -x wordnet-work.LATEST.sql.gz # Unpack dump +mysql -D wordnet_new < wordnet-work.LATEST.sql +``` It is then recommended to run `clean_wndb.sql` script to remove any mistakes in an unlikely case that the dump contains some, such as invalid enum values or invalid foreign keys. - $ mysql -D wordnet_new < clean_wndb.sql +```bash +mysql -D wordnet_new < clean_wndb.sql +``` Then, edit connection string in storage-dumps if necessary according to sqlalchemy format. Default values are all set to "wordnet", in the example DATABASE will be "wordnet_new". @@ -78,20 +127,26 @@ Default values are all set to "wordnet", in the example DATABASE will be "wordne To run next step make sure you have installed: - $ sudo apt-get install libmysqlclient-dev (when you are connecting to external mysql server) - $ pip install pymysql - $ pip install mysqlclient - $ pip install plwn_comments - $ pip install sqlalchemy +```bash +sudo apt-get install libmysqlclient-dev (when you are connecting to external mysql server) +pip install pymysql +pip install mysqlclient +pip install plwn_comments +pip install sqlalchemy +``` After that, the database can be read and saved into the API format. - >>> import plwn - >>> api = plwn.read("connection.txt", "database", "plwn-new.db", "sqlite3") +```python +import plwn +api = plwn.read("connection.txt", "database", "plwn-new.db", "sqlite3") +``` To load this version at a later date, use `plwn.load(path)` instead of `plwn.load_default()` - >>> api = plwn.load("storage-dumps/plwn-new.db") +```python +wn = plwn.load("storage-dumps/plwn-new.db") +``` Manually downloading API dumps @@ -100,12 +155,14 @@ Manually downloading API dumps In order to download one of the dumps available at https://minio.clarin-pl.eu/minio/public/models/: - latest model file plwn_dump_25-02-2020.sqlite - import plwn - plwn.download("optional_name") +```python +import plwn +plwn.download("/path/to/your/database/sqlite/dump") +``` + File will be downloaded to the current directory. -If optional_name is not provided default dump will be downloaded. -If optional_name is provided but doesn't match name of any available dumps, the process will fail -and display possible names. +If optional_name is not provided default dump will be downloaded (see ,,Setup'' section). +If optional_name is provided but doesn't match name of any available dumps, the process will fail and display possible names. You need to setup config.ini file. Licenses -- GitLab