SnlData


NameSnlData JSON
Version 1.1.3 PyPI version JSON
download
home_pagehttps://github.com/DiFronzo/SnlData
SummaryA lightweight Python library for Store Norske Leksikon and Lex.dk/Den Store Danske APIs.
upload_time2024-07-12 21:52:40
maintainerNone
docs_urlNone
authorDiFronzo
requires_python>=3.8
licenseGPLv3
keywords api snl dsd
VCS
bugtrack_url
requirements requests urllib3
Travis-CI
coveralls test coverage No coveralls.
            <p align="center">
  <a href="https://github.com/DiFronzo/snldata"><img alt="Logo" width="500" height="300" src="https://snldata.readthedocs.io/en/latest/_static/snldata_logo.svg"></a>
</p>
<p align="center">
  <a href="https://github.com/DiFronzo/snldata/releases" target="_blank"><img src="https://img.shields.io/badge/SnlData-1.1.3-blue" alt="SnlData version" /></a>
  <a href="https://github.com/DiFronzo/snldata/actions"><img alt="Actions Status" src="https://github.com/DiFronzo/SnlData/actions/workflows/test.yml/badge.svg"></a>
  <a href="https://snldata.readthedocs.io/en/latest/?badge=latest"><img alt="Documentation Status" src="https://readthedocs.org/projects/snldata/badge/?version=latest"></a>
  <a href="https://codecov.io/gh/DiFronzo/SnlData"><img alt="Coverage Status" src="https://codecov.io/gh/DiFronzo/SnlData/branch/master/graph/badge.svg"></a>
  <a href="https://app.travis-ci.com/DiFronzo/SnlData"><img alt="Build Status" src="https://api.travis-ci.com/DiFronzo/SnlData.svg?branch=master"></a>	
  <a href="https://github.com/DiFronzo/SnlData/blob/master/LICENSE"><img alt="License: GPLv3" src="https://img.shields.io/badge/License-GPLv3-blue.svg"></a>
  <a href="https://pepy.tech/project/snldata"><img alt="Downloads" src="https://pepy.tech/badge/snldata"></a>
  <a href="https://pypi.org/project/snldata/"><img alt="PyPI" src="https://img.shields.io/pypi/v/snldata"></a>
  <h4>A lightweight Python library for Store Norske Leksikon and Lex.dk/Den Store Danske APIs</h4>
</p>

## Installation

    pip3 install snldata

## Quick Start
Raw JSON
```python
import snldata

R = snldata.SnlSession()
R.search(query="fortolket programmeringsspråk", best=True) #Pick the one with the best rank
print(R.json)

```
Outputs: the JSON object
```
{
	"title": "fortolket programmeringsspråk",
	"url": "http://snl.no/fortolket_programmeringsspr%C3%A5k",
	"subject_url": "http://snl.no/.taxonomy/3689",
	"subject_title": "Programmering",
	"xhtml_body": "\u003cdiv\u003e\r\n\u003cp\u003eprogrammeringsspråk som ikke blir kompilert til objekt- eller maskinkode, men fortolket av et eget program på vertsmaskinen.\u003c/p\u003e\r\n\u003cp\u003eFordelen med slike språk er at man kan lage programmer som kan gjøre på mange forskjellige \u003ca class=\"crossref\" href=\"https://snl.no/datamaskin\"\u003edatamaskiner\u003c/a\u003e og \u003ca class=\"crossref\" href=\"https://snl.no/operativsystem\"\u003eoperativsystemer\u003c/a\u003e uten å skreddersy dem for hver enkelt plattform.\u003c/p\u003e\r\n\u003cp\u003eEksempler på fortolkede språk:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003ca class=\"crossref\" href=\"https://snl.no/Python_-_programmeringsspr%C3%A5k\"\u003ePython\u003c/a\u003e\u003c/li\u003e\r\n\u003cli\u003eJavascript\u003c/li\u003e\r\n\u003cli\u003e\u003ca class=\"crossref\" href=\"https://snl.no/Perl_-_IT\"\u003ePHP\u003c/a\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003ca class=\"crossref\" href=\"https://snl.no/Perl_-_IT\"\u003ePerl\u003c/a\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/div\u003e",
	"created_at": "2017-12-12T10:34:18.189+01:00",
	"changed_at": "2017-12-12T10:38:37.626+01:00",
	"license_name": "fri",
	"metadata_license_name": "fri",
	"metadata": {
		"lastname": "",
		"firstname": ""
	},
	"authors": [{
		"full_name": "Henrik Dvergsdal"
	}],
	"images": []
}
```
## Licenses for content from Store Norske Leksikon and Lex.dk 
| Licence | Description | Read more
| --- | --- | --- |
| `fri` | [Creative Commons](https://creativecommons.org/) **[CC-BY-SA-3.0](https://creativecommons.org/licenses/by-sa/3.0/)** license. Everyone is allowed to **share, use, copy and adapt** the text as long as **the author and Store norske leksikon** continues to be credited and the article retains the same free license for further use. | [SNL](https://meta.snl.no/fri_gjenbruk) [LEX](https://denstoredanske.lex.dk/.licenses/free)
| `begrenset gjenbruk/begrænset genbrug` | You **can't reuse, republish, or adapt** the article without first obtaining the author's permission.| [SNL](https://meta.snl.no/begrenset_gjenbruk) [LEX](https://denstoredanske.lex.dk/.licenses/restricted)

## Overview of sites/zones
### SNL
|     code    |       Website       |   Note 
| --- | --- | --- |
|     `snl`       |   https://snl.no/     | Default
|     `nbl`       | https://nbl.snl.no/   |        
|     `sml`       | https://sml.snl.no/   |        
|     `nkl`       | https://nkl.snl.no/   |        
|     `lille`     | https://lille.snl.no/ |     
| <s>`prototyping`</s> |          -          | <s>Unstable - for SNL</s>

### LEX
|     code    |       Website       |   Note 
| --- | --- | --- |
|     `dsd`     |   https://denstoredanske.lex.dk/   | 
|     `dlh`     | https://dansklitteraturshistorie.lex.dk/ |        
|     `dbl`     | https://biografiskleksikon.lex.dk/ |        
|     `gtl`     | https://teaterleksikon.lex.dk/ |
|     `nm`     | https://mytologi.lex.dk/ |
|     `do`     | https://danmarksoldtid.lex.dk/ |
|     `sl`     | https://symbolleksikon.lex.dk/ |
|     `dh`     | https://danmarkshistorien.lex.dk/ |
|     `hob`     | https://bornelitteratur.lex.dk/ |
|     `pd`     | https://pattedyratlas.lex.dk/ |
|     `nid`     | https://naturenidanmark.lex.dk/ |
|     `trap`     | https://trap.lex.dk/ |
| <s>`prototyping-lex`</s> |          -          | <s>Unstable - for LEX pages</s>

## Query
### Easy Query
- Main documentation (SNL): [API-dokumentasjon](https://meta.snl.no/API-dokumentasjon)

```python
import snldata

R = snldata.SnlSession()
R.search(query="Ole Ivars", best=True) #Pick the one with the best rank
print(R.url)

```
Outputs: `https://snl.no/Ole_Ivars`

```python
import snldata

R = snldata.SnlSession()
R.search(query="Ole Ivars") #Pick the three best results
for val in R.json:
    print(val["simple"]) #Summery for each index

```
Outputs: 
```
0. Ole Ivars (rank 576.6): Ole Ivars er et norsk danseband fra Hamar.
1. Spellemannprisen (rank 25.9): Spellemannprisen er den norske platebransjens årlige prisutdeling for å stimulere og markere plateproduksjonen i Norge.
2. danseband (rank 25.1): Danseband, ensemble som spiller til dans, betegner i dag vanligvis en instrumentbesetning som i pop og rock (vokal, elektrisk gitar og bass, keyboards, trommer, eventuelt også saksofon eller andre blåsere).
###Explaining of the values:
<index of the json file> <title> (rank <rank id>): <first sentence>
```
Pick the article you want from the example above:
```python
R._get(1)
print(R.title)
```
Outputs: `Spellemannprisen`

```python
import snldata

R = snldata.SnlSession()
R.search(zone='dsd', query="Python", best=True)  #Pick the one with the best rank
print(R.url)
```
Outputs: `https://denstoredanske.lex.dk/Python`

### Advance Query (best for prototyping api)
- Main documentation (SNL): [API-dokumentasjon - prototyping](https://meta.snl.no/API-dokumentasjon_-_prototyping)

**The prototyping API endpoint has been removed as of May 2023.**

### No result
If the API returns no results, `.json` will be given a empty list.
```python
import snldata

R = snldata.SnlSession()
R.search(zone='dsd', query="asdadasdasdad", best=True)  #Pick the one with the best rank
print(R.json)
```
Outputs: `{}`

```python
import snldata

R = snldata.SnlSession()
R.search(zone='dsd', query="jdfhdskjfhsjkdfhksdfh") #Pick the three best results, but there are none
R._get(0)
print(R.json)
```
Outputs: `{}`

<sup>All of the examples uses text that is [CC-BY-SA-3.0](https://creativecommons.org/licenses/by-sa/3.0). By at least one of the following authors: Henrik Dvergsdal, Jon Vidar Bergan, and Audun Kjus Aahlin. Read more about the license: [fri gjenbruk](https://meta.snl.no/fri_gjenbruk).</sup>

## To-do
- [ ] Fully support taxonomy
- [ ] Support for ".recent-activities" to JSON.
- [X] When zero results, return empty dict to tell the user there is no result.

## Reporting Issues
If you have suggestions, bugs or other issues specific to this library, file them [here](https://github.com/DiFronzo/SnlData/issues). Or just send me a pull request.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/DiFronzo/SnlData",
    "name": "SnlData",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "API SNL DSD",
    "author": "DiFronzo",
    "author_email": "root@vfiles.no",
    "download_url": "https://files.pythonhosted.org/packages/c9/8d/c1f75fcd1b7ef09698e0510ee0482697d16dabd4ad0e016c677beff55def/snldata-1.1.3.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <a href=\"https://github.com/DiFronzo/snldata\"><img alt=\"Logo\" width=\"500\" height=\"300\" src=\"https://snldata.readthedocs.io/en/latest/_static/snldata_logo.svg\"></a>\n</p>\n<p align=\"center\">\n  <a href=\"https://github.com/DiFronzo/snldata/releases\" target=\"_blank\"><img src=\"https://img.shields.io/badge/SnlData-1.1.3-blue\" alt=\"SnlData version\" /></a>\n  <a href=\"https://github.com/DiFronzo/snldata/actions\"><img alt=\"Actions Status\" src=\"https://github.com/DiFronzo/SnlData/actions/workflows/test.yml/badge.svg\"></a>\n  <a href=\"https://snldata.readthedocs.io/en/latest/?badge=latest\"><img alt=\"Documentation Status\" src=\"https://readthedocs.org/projects/snldata/badge/?version=latest\"></a>\n  <a href=\"https://codecov.io/gh/DiFronzo/SnlData\"><img alt=\"Coverage Status\" src=\"https://codecov.io/gh/DiFronzo/SnlData/branch/master/graph/badge.svg\"></a>\n  <a href=\"https://app.travis-ci.com/DiFronzo/SnlData\"><img alt=\"Build Status\" src=\"https://api.travis-ci.com/DiFronzo/SnlData.svg?branch=master\"></a>\t\n  <a href=\"https://github.com/DiFronzo/SnlData/blob/master/LICENSE\"><img alt=\"License: GPLv3\" src=\"https://img.shields.io/badge/License-GPLv3-blue.svg\"></a>\n  <a href=\"https://pepy.tech/project/snldata\"><img alt=\"Downloads\" src=\"https://pepy.tech/badge/snldata\"></a>\n  <a href=\"https://pypi.org/project/snldata/\"><img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/snldata\"></a>\n  <h4>A lightweight Python library for Store Norske Leksikon and Lex.dk/Den Store Danske APIs</h4>\n</p>\n\n## Installation\n\n    pip3 install snldata\n\n## Quick Start\nRaw JSON\n```python\nimport snldata\n\nR = snldata.SnlSession()\nR.search(query=\"fortolket programmeringsspr\u00e5k\", best=True) #Pick the one with the best rank\nprint(R.json)\n\n```\nOutputs: the JSON object\n```\n{\n\t\"title\": \"fortolket programmeringsspr\u00e5k\",\n\t\"url\": \"http://snl.no/fortolket_programmeringsspr%C3%A5k\",\n\t\"subject_url\": \"http://snl.no/.taxonomy/3689\",\n\t\"subject_title\": \"Programmering\",\n\t\"xhtml_body\": \"\\u003cdiv\\u003e\\r\\n\\u003cp\\u003eprogrammeringsspr\u00e5k som ikke blir kompilert til objekt- eller maskinkode, men fortolket av et eget program p\u00e5 vertsmaskinen.\\u003c/p\\u003e\\r\\n\\u003cp\\u003eFordelen med slike spr\u00e5k er at man kan lage programmer som kan gj\u00f8re p\u00e5 mange forskjellige \\u003ca class=\\\"crossref\\\" href=\\\"https://snl.no/datamaskin\\\"\\u003edatamaskiner\\u003c/a\\u003e og \\u003ca class=\\\"crossref\\\" href=\\\"https://snl.no/operativsystem\\\"\\u003eoperativsystemer\\u003c/a\\u003e uten \u00e5 skreddersy dem for hver enkelt plattform.\\u003c/p\\u003e\\r\\n\\u003cp\\u003eEksempler p\u00e5 fortolkede spr\u00e5k:\\u003c/p\\u003e\\r\\n\\u003cul\\u003e\\r\\n\\u003cli\\u003e\\u003ca class=\\\"crossref\\\" href=\\\"https://snl.no/Python_-_programmeringsspr%C3%A5k\\\"\\u003ePython\\u003c/a\\u003e\\u003c/li\\u003e\\r\\n\\u003cli\\u003eJavascript\\u003c/li\\u003e\\r\\n\\u003cli\\u003e\\u003ca class=\\\"crossref\\\" href=\\\"https://snl.no/Perl_-_IT\\\"\\u003ePHP\\u003c/a\\u003e\\u003c/li\\u003e\\r\\n\\u003cli\\u003e\\u003ca class=\\\"crossref\\\" href=\\\"https://snl.no/Perl_-_IT\\\"\\u003ePerl\\u003c/a\\u003e\\u003c/li\\u003e\\r\\n\\u003c/ul\\u003e\\r\\n\\u003c/div\\u003e\",\n\t\"created_at\": \"2017-12-12T10:34:18.189+01:00\",\n\t\"changed_at\": \"2017-12-12T10:38:37.626+01:00\",\n\t\"license_name\": \"fri\",\n\t\"metadata_license_name\": \"fri\",\n\t\"metadata\": {\n\t\t\"lastname\": \"\",\n\t\t\"firstname\": \"\"\n\t},\n\t\"authors\": [{\n\t\t\"full_name\": \"Henrik Dvergsdal\"\n\t}],\n\t\"images\": []\n}\n```\n## Licenses for content from Store Norske Leksikon and Lex.dk \n| Licence | Description | Read more\n| --- | --- | --- |\n| `fri` | [Creative Commons](https://creativecommons.org/) **[CC-BY-SA-3.0](https://creativecommons.org/licenses/by-sa/3.0/)** license. Everyone is allowed to **share, use, copy and adapt** the text as long as **the author and Store norske leksikon** continues to be credited and the article retains the same free license for further use. | [SNL](https://meta.snl.no/fri_gjenbruk) [LEX](https://denstoredanske.lex.dk/.licenses/free)\n| `begrenset gjenbruk/begr\u00e6nset genbrug` | You **can't reuse, republish, or adapt** the article without first obtaining the author's permission.| [SNL](https://meta.snl.no/begrenset_gjenbruk) [LEX](https://denstoredanske.lex.dk/.licenses/restricted)\n\n## Overview of sites/zones\n### SNL\n|     code    |       Website       |   Note \n| --- | --- | --- |\n|     `snl`       |   https://snl.no/     | Default\n|     `nbl`       | https://nbl.snl.no/   |        \n|     `sml`       | https://sml.snl.no/   |        \n|     `nkl`       | https://nkl.snl.no/   |        \n|     `lille`     | https://lille.snl.no/ |     \n| <s>`prototyping`</s> |          -          | <s>Unstable - for SNL</s>\n\n### LEX\n|     code    |       Website       |   Note \n| --- | --- | --- |\n|     `dsd`     |   https://denstoredanske.lex.dk/   | \n|     `dlh`     | https://dansklitteraturshistorie.lex.dk/ |        \n|     `dbl`     | https://biografiskleksikon.lex.dk/ |        \n|     `gtl`     | https://teaterleksikon.lex.dk/ |\n|     `nm`     | https://mytologi.lex.dk/ |\n|     `do`     | https://danmarksoldtid.lex.dk/ |\n|     `sl`     | https://symbolleksikon.lex.dk/ |\n|     `dh`     | https://danmarkshistorien.lex.dk/ |\n|     `hob`     | https://bornelitteratur.lex.dk/ |\n|     `pd`     | https://pattedyratlas.lex.dk/ |\n|     `nid`     | https://naturenidanmark.lex.dk/ |\n|     `trap`     | https://trap.lex.dk/ |\n| <s>`prototyping-lex`</s> |          -          | <s>Unstable - for LEX pages</s>\n\n## Query\n### Easy Query\n- Main documentation (SNL): [API-dokumentasjon](https://meta.snl.no/API-dokumentasjon)\n\n```python\nimport snldata\n\nR = snldata.SnlSession()\nR.search(query=\"Ole Ivars\", best=True) #Pick the one with the best rank\nprint(R.url)\n\n```\nOutputs: `https://snl.no/Ole_Ivars`\n\n```python\nimport snldata\n\nR = snldata.SnlSession()\nR.search(query=\"Ole Ivars\") #Pick the three best results\nfor val in R.json:\n    print(val[\"simple\"]) #Summery for each index\n\n```\nOutputs: \n```\n0. Ole Ivars (rank 576.6): Ole Ivars er et norsk danseband fra Hamar.\n1. Spellemannprisen (rank 25.9): Spellemannprisen er den norske platebransjens \u00e5rlige prisutdeling for \u00e5 stimulere og markere plateproduksjonen i Norge.\n2. danseband (rank 25.1): Danseband, ensemble som spiller til dans, betegner i dag vanligvis en instrumentbesetning som i pop og rock (vokal, elektrisk gitar og bass, keyboards, trommer, eventuelt ogs\u00e5 saksofon eller andre bl\u00e5sere).\n###Explaining of the values:\n<index of the json file> <title> (rank <rank id>): <first sentence>\n```\nPick the article you want from the example above:\n```python\nR._get(1)\nprint(R.title)\n```\nOutputs: `Spellemannprisen`\n\n```python\nimport snldata\n\nR = snldata.SnlSession()\nR.search(zone='dsd', query=\"Python\", best=True)  #Pick the one with the best rank\nprint(R.url)\n```\nOutputs: `https://denstoredanske.lex.dk/Python`\n\n### Advance Query (best for prototyping api)\n- Main documentation (SNL): [API-dokumentasjon - prototyping](https://meta.snl.no/API-dokumentasjon_-_prototyping)\n\n**The prototyping API endpoint has been removed as of May 2023.**\n\n### No result\nIf the API returns no results, `.json` will be given a empty list.\n```python\nimport snldata\n\nR = snldata.SnlSession()\nR.search(zone='dsd', query=\"asdadasdasdad\", best=True)  #Pick the one with the best rank\nprint(R.json)\n```\nOutputs: `{}`\n\n```python\nimport snldata\n\nR = snldata.SnlSession()\nR.search(zone='dsd', query=\"jdfhdskjfhsjkdfhksdfh\") #Pick the three best results, but there are none\nR._get(0)\nprint(R.json)\n```\nOutputs: `{}`\n\n<sup>All of the examples uses text that is [CC-BY-SA-3.0](https://creativecommons.org/licenses/by-sa/3.0). By at least one of the following authors: Henrik Dvergsdal, Jon Vidar Bergan, and Audun Kjus Aahlin. Read more about the license: [fri gjenbruk](https://meta.snl.no/fri_gjenbruk).</sup>\n\n## To-do\n- [ ] Fully support taxonomy\n- [ ] Support for \".recent-activities\" to JSON.\n- [X] When zero results, return empty dict to tell the user there is no result.\n\n## Reporting Issues\nIf you have suggestions, bugs or other issues specific to this library, file them [here](https://github.com/DiFronzo/SnlData/issues). Or just send me a pull request.\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "A lightweight Python library for Store Norske Leksikon and Lex.dk/Den Store Danske APIs.",
    "version": "1.1.3",
    "project_urls": {
        "Homepage": "https://github.com/DiFronzo/SnlData"
    },
    "split_keywords": [
        "api",
        "snl",
        "dsd"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c1537043d71d51653c3678df8a1d68459b60b130637c26c2c0972f88efbe712",
                "md5": "066e1749d1181c1134affaa76562ab5b",
                "sha256": "1963e579385fa961ddde32dfef3b57f6ed1e3251ba513900ef89247db8198f02"
            },
            "downloads": -1,
            "filename": "SnlData-1.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "066e1749d1181c1134affaa76562ab5b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 20389,
            "upload_time": "2024-07-12T21:52:39",
            "upload_time_iso_8601": "2024-07-12T21:52:39.007414Z",
            "url": "https://files.pythonhosted.org/packages/4c/15/37043d71d51653c3678df8a1d68459b60b130637c26c2c0972f88efbe712/SnlData-1.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c98dc1f75fcd1b7ef09698e0510ee0482697d16dabd4ad0e016c677beff55def",
                "md5": "d802cd8b06baac7e725de30efd5b283d",
                "sha256": "5b84fb6a8ad41dfa4a132d6b742365047c2df10f1ff84a801b433c6632cecb62"
            },
            "downloads": -1,
            "filename": "snldata-1.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d802cd8b06baac7e725de30efd5b283d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 21529,
            "upload_time": "2024-07-12T21:52:40",
            "upload_time_iso_8601": "2024-07-12T21:52:40.501080Z",
            "url": "https://files.pythonhosted.org/packages/c9/8d/c1f75fcd1b7ef09698e0510ee0482697d16dabd4ad0e016c677beff55def/snldata-1.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-12 21:52:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DiFronzo",
    "github_project": "SnlData",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    "<=",
                    "2.32.3"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "1.26.12"
                ]
            ]
        }
    ],
    "lcname": "snldata"
}
        
Elapsed time: 0.78114s