wdgrid API Documentation
pareto
Created on 2022-03-21
@author: wf
Pareto
Bases: object
Pareto level holder
Source code in wd/pareto.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
__init__(level=1)
Constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level(int) |
the pareto level |
required |
Source code in wd/pareto.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
asDict()
return me as a dict
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
my values as a dict |
Source code in wd/pareto.py
54 55 56 57 58 59 60 61 62 63 64 65 |
|
ratioInLevel(ratio)
check whether the given ratio is in this level
Source code in wd/pareto.py
33 34 35 36 37 38 |
|
query_view
Created on 2024-01-04
@author: wf
QueryView
widget to display queries
Source code in wd/query_view.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
__init__(webserver, name, sparql_endpoint)
Initialize the QueryView object with a given webserver and name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webserver |
NiceGuiWebserver
|
The web server instance to be used. |
required |
name |
str
|
The name identifier for the query display. |
required |
sparql_endpoint(endpoint) |
the SPARQL endpoint to use |
required |
Source code in wd/query_view.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
setup()
Set up the UI components for the query display.
Source code in wd/query_view.py
36 37 38 39 40 41 42 43 |
|
show_query(sparql_query)
Update the display with a new SPARQL query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sparql_query |
str
|
The SPARQL query string to be displayed. |
required |
Source code in wd/query_view.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
truly_tabular_display
Created on 2024-01-04
@author: wf
PropertySelection
select properties
Source code in wd/truly_tabular_display.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
checkbox_cols: list
property
get all my checkbox columns
__init__(inputList, total, paretoLevels, minFrequency)
Constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
propertyList(list) |
the list of properties to show |
required | |
total(int) |
total number of properties |
required | |
paretolLevels |
a dict of paretoLevels with the key corresponding to the level |
required | |
minFrequency(float) |
the minimum frequency of the properties to select in percent |
required |
Source code in wd/truly_tabular_display.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
hasMinFrequency(record)
Check if the frequency of the given property record is greater than the minimal frequency
Returns:
Type | Description |
---|---|
bool
|
True if property frequency is greater or equal than the minFrequency. Otherwise False |
Source code in wd/truly_tabular_display.py
165 166 167 168 169 170 171 172 173 |
|
prepare()
prepare the propertyList
Parameters:
Name | Type | Description | Default |
---|---|---|---|
total(int) |
the total number of records |
required | |
paretoLevels(list) |
the pareto Levels to use |
required |
Source code in wd/truly_tabular_display.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
select()
select all properties that fulfill hasMinFrequency
Returns:
Type | Description |
---|---|
List[Tuple[str, dict]]
|
list of all selected properties as tuple list consisting of property id and record |
Source code in wd/truly_tabular_display.py
175 176 177 178 179 180 181 182 183 184 185 186 |
|
TrulyTabularConfig
dataclass
Configuration class for Truly Tabular operations.
Attributes:
Name | Type | Description |
---|---|---|
lang |
str
|
Language code (default is "en"). |
list_separator |
str
|
Character used to separate items in lists (default is "|"). |
endpoint_name |
str
|
Name of the endpoint to use (default is "wikidata"). |
Source code in wd/truly_tabular_display.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
__post_init__()
Post-initialization to setup additional attributes.
Source code in wd/truly_tabular_display.py
44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
setup_ui(webserver)
setup the user interface
Source code in wd/truly_tabular_display.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
TrulyTabularDisplay
Displays a truly tabular analysis for a given Wikidata item
Source code in wd/truly_tabular_display.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
|
__init__(solution, qid)
constructor
Source code in wd/truly_tabular_display.py
247 248 249 250 251 252 253 254 255 256 257 258 |
|
createTrulyTabular(itemQid, propertyIds=[])
create a Truly Tabular configuration for my configure endpoint and the given itemQid and propertyIds
Parameters:
Name | Type | Description | Default |
---|---|---|---|
itemQid(str) |
e.g. Q5 human |
required | |
propertyIds(list) |
list of property Ids (if any) such as P17 country |
required |
Source code in wd/truly_tabular_display.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
generateQueries()
async
generate and show the queries
Source code in wd/truly_tabular_display.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
|
getPropertyIdMap()
async
get the map of selected property ids with generation specs
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict
|
a dict of list |
Source code in wd/truly_tabular_display.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
|
get_stats_rows(property_grid_rows)
get the statistic rows for the given property_grid_rows
Source code in wd/truly_tabular_display.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
|
isTimeoutException(ex)
staticmethod
Checks if the given exception is a query timeout exception
Returns:
Type | Description |
---|---|
True if the given exception is caused by a query timeout |
Source code in wd/truly_tabular_display.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
on_generate_button_click(_event)
async
handle the generate button click
Source code in wd/truly_tabular_display.py
459 460 461 462 463 464 465 466 467 |
|
on_min_property_frequency_change(_event)
async
handle a change in the minimum property frequency input
Source code in wd/truly_tabular_display.py
469 470 471 472 473 474 475 476 477 478 479 480 |
|
on_pareto_change(_event)
async
handle changes in the pareto level
Source code in wd/truly_tabular_display.py
482 483 484 485 486 487 488 489 490 |
|
on_property_grid_selection_change(event)
async
the property grid selection has changed
Source code in wd/truly_tabular_display.py
632 633 634 635 636 637 638 639 |
|
prepare_generation_specs()
prepare the interactive generation specification
Source code in wd/truly_tabular_display.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
|
setup()
set up the user interface
Source code in wd/truly_tabular_display.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
update_display()
async
update the display
Source code in wd/truly_tabular_display.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
|
update_item_count_view()
update the item count
Source code in wd/truly_tabular_display.py
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
|
update_properties_table(mfp_query)
update my properties table
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mfp_query(Query) |
the query for the most frequently used properties |
required |
Source code in wd/truly_tabular_display.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
|
update_property_query_view(total)
update the property query view
Source code in wd/truly_tabular_display.py
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
|
update_property_stats()
update the property statistics
Source code in wd/truly_tabular_display.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
|
wikiTrulyTabularPropertyStats(itemId, propertyId)
get the truly tabular property statistics
Parameters:
Name | Type | Description | Default |
---|---|---|---|
itemId(str) |
the Wikidata item identifier |
required | |
propertyId(str) |
the property id |
required |
Source code in wd/truly_tabular_display.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
|
version
Created on 2024-01-02
@author: wf
Version
dataclass
Bases: object
Version handling for wdgrid
Source code in wd/version.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
wdgrid_cmd
Created on 2024-01-03
@author: wf
WdgridCmd
Bases: WebserverCmd
Command line for wiki data grid web server
Source code in wd/wdgrid_cmd.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
getArgParser(description, version_msg)
override the default argparser call
Source code in wd/wdgrid_cmd.py
21 22 23 24 25 26 27 28 29 30 31 32 |
|
main(argv=None)
main call
Source code in wd/wdgrid_cmd.py
35 36 37 38 39 40 41 |
|
wditem_search
Created on 2024-01-03
@author: wf
WikidataItemSearch
wikidata item search
Source code in wd/wditem_search.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
__init__(webserver, record_filter=None)
Initialize the WikidataItemSearch with the given webserver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webserver |
NiceGuiWebserver
|
The webserver to attach the search UI. |
required |
record_filter(Callable) |
callback for displayed found records |
required |
Source code in wd/wditem_search.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
debounced_search()
async
Waits for a period of inactivity and then performs the search.
Source code in wd/wditem_search.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
get_selection_view_lod(wd_search_result)
Convert the Wikidata search result list of dict to a selection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wd_search_result |
List[Dict[str, Any]]
|
The search results from Wikidata. |
required |
Returns:
Type | Description |
---|---|
dict
|
List[Dict[str, Any]]: The list of dictionaries formatted for view. |
Source code in wd/wditem_search.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
on_search_change(_args)
async
react on changes in the search input
Source code in wd/wditem_search.py
58 59 60 61 62 63 64 65 66 67 |
|
setup()
setup the user interface
Source code in wd/wditem_search.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
webserver
Created on 2024-01-03
@author: wf
WdgridSolution
Bases: InputWebSolution
Wikidata Grid client specific UI
Source code in wd/webserver.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
configure_settings()
extra settings
Source code in wd/webserver.py
73 74 75 76 77 |
|
home()
async
provide the main content page
Source code in wd/webserver.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
prepare_ui()
overrideable configuration
Source code in wd/webserver.py
79 80 81 82 83 |
|
truly_tabular(qid)
async
show a truly tabular analysis of the given Wikidata id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qid(str) |
the Wikidata id of the item to analyze |
required |
Source code in wd/webserver.py
60 61 62 63 64 65 66 67 68 69 70 71 |
|
WdgridWebServer
Bases: InputWebserver
Server for Wikidata Grid
Source code in wd/webserver.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
__init__()
Constructs all the necessary attributes for the WebServer object.
Source code in wd/webserver.py
38 39 40 41 42 43 44 45 46 47 |
|
get_config()
classmethod
get the configuration for this Webserver
Source code in wd/webserver.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|