Giter VIP home page Giter VIP logo

Comments (2)

galtay avatar galtay commented on July 18, 2024

Hi igolkotek, thanks for opening the issue. I just tested your use case and I don't see the problem. The item Q1800 (currently) has four statements for P131. They are,

  • Q1356097 Ernakulam district (rank=deprecated)
  • Q1186 Kerala (rank=normal)
  • Q1538311 Travancore-Cochin (rank=normal)
  • Q150056 Kingdom of Cochin (rank=normal)

You can see the ranks in the little icons next to each target data value that hvae a circle in the middle and a triangle on the top and bottom.

image

The definition of "truthy" statements from the docs is,
β€œTruthy statements represent statements that have the best non-deprecated rank for a given property. Namely, if there is a preferred statement for a property P, then only preferred statements for P will be considered truthy. Otherwise, all normal-rank statements for P are considered truthy.”

https://qwikidata.readthedocs.io/en/stable/qwikidata.entity.html#qwikidata.entity.ClaimsMixin.get_truthy_claim_group

In this case, that makes the last 3 statements

  • Q1186 Kerala (rank=normal)
  • Q1538311 Travancore-Cochin (rank=normal)
  • Q150056 Kingdom of Cochin (rank=normal)

the truthy ones. That's what I get if I run the following code,

from qwikidata.entity import WikidataItem                                                                                   
from qwikidata.linked_data_interface import get_entity_dict_from_api                                                        
                                                                                                                            
                                                                                                                            
q1800_dict = get_entity_dict_from_api('Q1800')                                                                              
q1800 = WikidataItem(q1800_dict)                                                                                            
                                                                                                                            
print('all claim groups')                                                                                                   
print('=' * 60)                                                                                                             
p131_claim_group = q1800.get_claim_group('P131')                                                                            
for claim in p131_claim_group:                                                                                              
    print(claim)                                                                                                            
    print()                                                                                                                 
                                                                                                                            
print('truthy  claim groups')                                                                                               
print('=' * 60)                                                                                                             
p131_truthy_claim_group = q1800.get_truthy_claim_group('P131')                                                              
for claim in p131_truthy_claim_group:                                                                                       
    print(claim)                                                                                                            
    print()
all claim groups
============================================================
WikidataClaim(type=statement, rank=deprecated, mainsnak=WikidataSnak(snaktype=value, property_id=P131, snak_datatype=wikibase-item, value_datatype=wikibase-entityid, datavalue=WikibaseEntityId(id=Q1356097)), qualifiers=OrderedDict())

WikidataClaim(type=statement, rank=normal, mainsnak=WikidataSnak(snaktype=value, property_id=P131, snak_datatype=wikibase-item, value_datatype=wikibase-entityid, datavalue=WikibaseEntityId(id=Q1186)), qualifiers=OrderedDict([('P580', [WikidataQualifier(hash=1f8c91b2570e6f837a39a5baebf3dc1fcf5ef4d2, snak=WikidataSnak(snaktype=value, property_id=P580, snak_datatype=time, value_datatype=time, datavalue=Time(time=+1956-11-01T00:00:00Z, precision=11)))])]))

WikidataClaim(type=statement, rank=normal, mainsnak=WikidataSnak(snaktype=value, property_id=P131, snak_datatype=wikibase-item, value_datatype=wikibase-entityid, datavalue=WikibaseEntityId(id=Q1538311)), qualifiers=OrderedDict([('P580', [WikidataQualifier(hash=6940cae70ef8512392b0e62f1e5148bf1da05c47, snak=WikidataSnak(snaktype=value, property_id=P580, snak_datatype=time, value_datatype=time, datavalue=Time(time=+1949-07-01T00:00:00Z, precision=11)))]), ('P582', [WikidataQualifier(hash=134e737dfcddb40a4e25328b6e0a44d9b560384b, snak=WikidataSnak(snaktype=value, property_id=P582, snak_datatype=time, value_datatype=time, datavalue=Time(time=+1956-11-01T00:00:00Z, precision=11)))])]))

WikidataClaim(type=statement, rank=normal, mainsnak=WikidataSnak(snaktype=value, property_id=P131, snak_datatype=wikibase-item, value_datatype=wikibase-entityid, datavalue=WikibaseEntityId(id=Q150056)), qualifiers=OrderedDict([('P582', [WikidataQualifier(hash=37bcaa3fd7ae0fa53da1a79a90438cdc9175d281, snak=WikidataSnak(snaktype=value, property_id=P582, snak_datatype=time, value_datatype=time, datavalue=Time(time=+1949-07-01T00:00:00Z, precision=11)))])]))

truthy  claim groups
============================================================
WikidataClaim(type=statement, rank=normal, mainsnak=WikidataSnak(snaktype=value, property_id=P131, snak_datatype=wikibase-item, value_datatype=wikibase-entityid, datavalue=WikibaseEntityId(id=Q1186)), qualifiers=OrderedDict([('P580', [WikidataQualifier(hash=1f8c91b2570e6f837a39a5baebf3dc1fcf5ef4d2, snak=WikidataSnak(snaktype=value, property_id=P580, snak_datatype=time, value_datatype=time, datavalue=Time(time=+1956-11-01T00:00:00Z, precision=11)))])]))

WikidataClaim(type=statement, rank=normal, mainsnak=WikidataSnak(snaktype=value, property_id=P131, snak_datatype=wikibase-item, value_datatype=wikibase-entityid, datavalue=WikibaseEntityId(id=Q1538311)), qualifiers=OrderedDict([('P580', [WikidataQualifier(hash=6940cae70ef8512392b0e62f1e5148bf1da05c47, snak=WikidataSnak(snaktype=value, property_id=P580, snak_datatype=time, value_datatype=time, datavalue=Time(time=+1949-07-01T00:00:00Z, precision=11)))]), ('P582', [WikidataQualifier(hash=134e737dfcddb40a4e25328b6e0a44d9b560384b, snak=WikidataSnak(snaktype=value, property_id=P582, snak_datatype=time, value_datatype=time, datavalue=Time(time=+1956-11-01T00:00:00Z, precision=11)))])]))

WikidataClaim(type=statement, rank=normal, mainsnak=WikidataSnak(snaktype=value, property_id=P131, snak_datatype=wikibase-item, value_datatype=wikibase-entityid, datavalue=WikibaseEntityId(id=Q150056)), qualifiers=OrderedDict([('P582', [WikidataQualifier(hash=37bcaa3fd7ae0fa53da1a79a90438cdc9175d281, snak=WikidataSnak(snaktype=value, property_id=P582, snak_datatype=time, value_datatype=time, datavalue=Time(time=+1949-07-01T00:00:00Z, precision=11)))])]))

let me know if that helps!

thanks again,
-Gabriel

from qwikidata.

igolkotek avatar igolkotek commented on July 18, 2024

Thank you )

from qwikidata.

Related Issues (9)

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.