Git Product home page Git Product logo

lexdata's Introduction

Python bot framework for Lexemes on Wikidata

This is a small library to create bots, scripts and tools about Wikidata Lexemes. It's philosophy is to have a transparent thin layer on top of the internal datastuctures enriched with convenient functions without hiding the power of the access to the internals.

LexData is still in beta phase and there fore some features are missing and functions might be renamed in future.

The code of AitalvivemBot was used as a starting point, but probably theres not a single line of code that wasn't rewritten.

Install from pypi:

 $ pip install LexData

Read the docs: https://nudin.github.io/LexData/

lexdata's People

Contributors

aitalvivem avatar nudin avatar uziel302 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lexdata's Issues

Confusing forms and lexemes when getting lexemes

If there is no lexeme movies, but there is movie with the form movies, "get_or_create_lexeme" will get you the lexeme movie, so if you want to update sense "cinema" it will be wrong. I had about 300 lexemes mixed up due to this issue, while running a bot.

Creating an English lexeme works, but crashes

When using get_or_create_lexeme to create new English lexemes, the lexeme is created, but the program then crashes.

Program:

import LexData
from LexData.languages import en
repo = LexData.WikidataSession("Blinry", "foobar")
l = LexData.get_or_create_lexeme(repo, "watermelon", en, "Q1084")

Error:

Traceback (most recent call last):
  File "mod.py", line 18, in <module>
    l = LexData.get_or_create_lexeme(repo, "watermelon", en, "Q1084")
  File "/usr/lib/python3.7/site-packages/LexData/__init__.py", line 532, in get_or_create_lexeme
    return create_lexeme(repo, lemma, lang, catLex)
  File "/usr/lib/python3.7/site-packages/LexData/__init__.py", line 580, in create_lexeme
    lexeme.createClaims(claims)
  File "/usr/lib/python3.7/site-packages/LexData/__init__.py", line 446, in createClaims
    self.__setClaims__(self["id"], claims)
  File "/usr/lib/python3.7/site-packages/LexData/__init__.py", line 457, in __setClaims__
    for cle, values in claims.items():
AttributeError: 'NoneType' object has no attribute 'items'

Consider using pywikiapi for the low-level api calls?

Hi, I think my pywikiapi library would be a perfect fit for you -- it will take care of the low-level communication with the mediawiki, while you can focus on the lexeme-related logic? Just an idea. I have been using this lib in many of my projects, and it was originally written to be used by pywikibot library as a low-level layer (but hasn't been integrated yet).

P.S. I'm writing a big bot to import all of ru-wiktionary into lexemes at the moment -- https://github.com/nyurik/lexicator (a bit work in progress, the main.py might not work properly). It uses that lib too.

Getting value of a specific property

Caveat: I'm a newbie so maybe it already exist.

How do I get the value of a specific property? L.claims.values() gives me all the values but I only want one (P5187 in my specific case).

Can't create lexemes in unsupported languages

I want to enter lexemes in a language that doesn't have an ISO code yet, like L1. LexData crashes if I try that. I wonder if there would be a workaround?

Program:

import LexData
tok = LexData.Language("mis-x-Q36846", "Q36846")
repo = LexData.WikidataSession("Blinry", "foobar")
l = LexData.get_or_create_lexeme(repo, "ike", tok, "Q34698")

Error:

Traceback (most recent call last):
  File "mod.py", line 17, in <module>
    l = LexData.get_or_create_lexeme(repo, "ike", tok, "Q34698")
  File "/usr/lib/python3.7/site-packages/LexData/__init__.py", line 519, in get_or_create_lexeme
    for item in DATA["search"]:
KeyError: 'search'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.