schemacast.bench.score¶
Score a cast episode against its expected graph.
No model judges. Entities match by identity: the primary key of a natural type,
the digest of a hash type, or any complete secondary identity. A type with no
identity of its own (assigned, blank) matches by equal property values or by a
quote overlapping the expected one. Edges match by relation and matched
endpoints; an edge between the right endpoints the wrong way round counts as
reversed. Property values compare after coercion by their field, strings
ignoring case and runs of whitespace. An expected edge may end at a known
entity by its ref (k1…); it matches by ref, and known entities are not
counted as entities.
Every figure is a pair of integer counts, so cases pool by summing and a rate is read off the pooled counts.
Attributes¶
NOT_CONFORMANCE = frozenset({'quote_not_found', 'value_not_in_quote'}) | CONSEQUENTIAL
module-attribute
¶
Classes¶
Counts
¶
Bases: BaseModel
Additive counts for one episode, a case, a family or a run.
Source code in schemacast/bench/score.py
Attributes¶
billed_input_tokens = 0
class-attribute
instance-attribute
¶
billed_output_tokens = 0
class-attribute
instance-attribute
¶
direction_fixed = 0
class-attribute
instance-attribute
¶
edges_expected = 0
class-attribute
instance-attribute
¶
edges_first = 0
class-attribute
instance-attribute
¶
edges_matched = 0
class-attribute
instance-attribute
¶
edges_produced = 0
class-attribute
instance-attribute
¶
edges_reversed = 0
class-attribute
instance-attribute
¶
emitted_final = 0
class-attribute
instance-attribute
¶
emitted_first = 0
class-attribute
instance-attribute
¶
entities_expected = 0
class-attribute
instance-attribute
¶
entities_matched = 0
class-attribute
instance-attribute
¶
entities_produced = 0
class-attribute
instance-attribute
¶
episodes = 0
class-attribute
instance-attribute
¶
failed = 0
class-attribute
instance-attribute
¶
forbidden_expected = 0
class-attribute
instance-attribute
¶
forbidden_written = 0
class-attribute
instance-attribute
¶
gold_edges = 0
class-attribute
instance-attribute
¶
gold_edges_in_slice = 0
class-attribute
instance-attribute
¶
gold_types = 0
class-attribute
instance-attribute
¶
gold_types_in_slice = 0
class-attribute
instance-attribute
¶
gold_types_seeded = 0
class-attribute
instance-attribute
¶
input_tokens = 0
class-attribute
instance-attribute
¶
mention_agree = 0
class-attribute
instance-attribute
¶
nonconforming_final = 0
class-attribute
instance-attribute
¶
nonconforming_first = 0
class-attribute
instance-attribute
¶
output_tokens = 0
class-attribute
instance-attribute
¶
picks_correct = 0
class-attribute
instance-attribute
¶
picks_expected = 0
class-attribute
instance-attribute
¶
picks_linked = 0
class-attribute
instance-attribute
¶
picks_offered = 0
class-attribute
instance-attribute
¶
picks_rejected = 0
class-attribute
instance-attribute
¶
picks_wrong = 0
class-attribute
instance-attribute
¶
properties_first = 0
class-attribute
instance-attribute
¶
props_expected = 0
class-attribute
instance-attribute
¶
props_matched = 0
class-attribute
instance-attribute
¶
props_produced = 0
class-attribute
instance-attribute
¶
recast_added = 0
class-attribute
instance-attribute
¶
recast_duplicated = 0
class-attribute
instance-attribute
¶
recast_minted = 0
class-attribute
instance-attribute
¶
recast_vertices = 0
class-attribute
instance-attribute
¶
repairs = 0
class-attribute
instance-attribute
¶
requests = 0
class-attribute
instance-attribute
¶
sliced = 0
class-attribute
instance-attribute
¶
spans_checked = 0
class-attribute
instance-attribute
¶
spans_hit = 0
class-attribute
instance-attribute
¶
undeclared_edge_first = 0
class-attribute
instance-attribute
¶
undeclared_property_first = 0
class-attribute
instance-attribute
¶
unfaithful_value_first = 0
class-attribute
instance-attribute
¶
ungrounded_first = 0
class-attribute
instance-attribute
¶
unknown_type_first = 0
class-attribute
instance-attribute
¶
vertices_first = 0
class-attribute
instance-attribute
¶
Methods:¶
Misses
¶
Bases: BaseModel
What one episode's cast and its expected graph do not share, by quote.
Expected items no produced item matched, and produced items that matched no expected or allowed item (a forbidden match is listed and marked).
Source code in schemacast/bench/score.py
Functions:¶
gold_vertices(graph, schema, text, context=None)
¶
Expected vertices with coerced properties, identity keys and spans.
Raises:
| Type | Description |
|---|---|
ValueError
|
a type or property the schema does not declare, or a value its field refuses. |
Source code in schemacast/bench/score.py
identity_keys(vertex, props)
¶
Every key props complete: the primary first, then secondaries.
Source code in schemacast/bench/score.py
ref_handles(outcome, expected, schema, text, context=None)
¶
Produced mention ref → the expected vertex handle it matched.
Source code in schemacast/bench/score.py
score_episode(outcome, expected, schema, text, usage=None, context=None, misses=None, known=())
¶
Counts for one cast episode; context maps context source ids to text.
misses, when given, is filled with what the cast and the expected graph do not share. known are the episode's known entities, whose refs expected edges may name.
Source code in schemacast/bench/score.py
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 | |
score_picks(picks, refs, spec)
¶
Pick counts: a pick is correct when what it links is the expected entity, or nothing when none fits. A mention the cast did not stage counts as missed.
Source code in schemacast/bench/score.py
score_recast(first, second, schema)
¶
What a second cast of the same episode would add to a store that upserts.
A natural or hash identity the first cast lacked is an added vertex; an assigned or blank one is a duplicate, since nothing ties it to the first.