Assembler
The assembler: it applies classify and premise records to a graph through the core's edits.
A classify record types one chunk of the document, or splits it into clauses and types each clause.
Its fields are the type, the form, the nodes it rests on, and a hedge phrase; it has no field for a
credence. Every base and strength the assembler writes is therefore the rubric's: annotate
gives a typed node its type's base and a rests-on relation its edge rule's strength. The one value
the text sets is Node.stated, read from the rubric's [hedges] table for the phrase the model
located; stated is used by diagnostics only, never by inference.
A premise record names a conclusion and the premises it needs beside those it rests on. A premise
stated_at a chunk becomes a requires from that chunk, through annotate, with the edge
rule's strength. A statement becomes an analyst node of type assumption, with no source and
the rubric's premises.base, joined to the conclusion by a requires of premises.strength.
Analyst nodes whose normalised statements are identical are one node with several requires.
Each is named a-<n>: n counts from 1, in the order the nodes are created (conclusions in
document order, then each record's premises in its order), skipping any id the graph already has.
The number is not zero-padded, since it is assigned before the total is known. A replay creates the
same nodes in the same order, so it gives them the same ids.
Records are applied in document order, each as a whole or not at all. A record the core refuses is not applied and not dropped: it is returned as a rejection with the core's error code, and its node stays as it was.
Assembly
dataclass
¶
The result of applying a set of records.
Attributes:
| Name | Type | Description |
|---|---|---|
graph |
Graph
|
The graph with every accepted record applied. |
rejections |
list[dict[str, Any]]
|
The records not applied, in the order they were tried, each as |
unmapped |
list[dict[str, str]]
|
The hedge phrases found in their node's text that the rubric's |
Source code in src/credencegraph_extract/assemble.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
PremiseAssembly
dataclass
¶
The result of applying a set of premise records.
Attributes:
| Name | Type | Description |
|---|---|---|
graph |
Graph
|
The graph with every accepted record applied. |
rejections |
list[dict[str, Any]]
|
The records not applied, as in |
overflow |
list[dict[str, str]]
|
The statements not added because their conclusion already had
|
Source code in src/credencegraph_extract/assemble.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
assemble(graph, rubric, records)
¶
Apply classify records in document order through the core's split and annotate.
Each record is applied as a whole or not at all. One is rejected, and its node left as it was,
when it is malformed, names a node the graph lacks or one that is not a document chunk, repeats
the node of an earlier record, or the core refuses one of its edits: an
unknown type, a form not found in the text, a clause that does not occur exactly once, a
rests-on node of a type the edge rule does not allow. A hedge phrase that is not a substring of
its node's text rejects the record too. One the text contains sets Node.stated to the
rubric's credence for it, or, if [hedges] does not list it, is returned as unmapped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph, left unchanged. |
required |
rubric
|
Rubric
|
The rubric. |
required |
records
|
Sequence[Any]
|
The records, as the model returned them. |
required |
Returns:
| Type | Description |
|---|---|
Assembly
|
The graph, the rejections and the unmapped hedge phrases. |
Source code in src/credencegraph_extract/assemble.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
assemble_premises(graph, rubric, records)
¶
Apply premise records in document order of their conclusions.
Each record is applied as a whole or not at all. One is rejected, and its conclusion left as it
was, when it is malformed, names a node the graph lacks or one that is not a document node of a
type in premises.for, repeats the conclusion of an earlier record, or
the core refuses a stated_at link: a node of a type the edge rule does not allow, a relation
that already exists or would close a cycle. A conclusion takes at most
premises.max_per_conclusion analyst premises; the statements beyond are returned as overflow,
not added. A statement repeated within one record is one premise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph, left unchanged. |
required |
rubric
|
Rubric
|
The rubric; it must pass |
required |
records
|
Sequence[Any]
|
The records, as the model returned them. |
required |
Returns:
| Type | Description |
|---|---|
PremiseAssembly
|
The graph, the rejections and the overflow. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the rubric cannot take premise records. |
Source code in src/credencegraph_extract/assemble.py
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 | |
edge_rules_not_requires(rubric)
¶
Return the types whose edge rule creates a relation other than requires.
Text may only add requires relations: with no other parents, a node's credence cannot exceed
its type's base, whatever the text says. A supports edge rule would let a document raise the
credence of its own claims, so a rubric with one cannot be used for extraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rubric
|
Rubric
|
The rubric. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The names of those types, in declaration order. |
Source code in src/credencegraph_extract/assemble.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
fixes(graph, rubric, record)
¶
Say what to change in a classify record so the assembler can apply it, as instructions to the model.
The record is read against the graph it was applied to and the rubric, independently of the error the
core gave: a node id that is not a chunk (and, for an id such as s-2a, how a chunk is split), a type
a chunk may not have, rests_on on a type that rests on nothing or naming nodes of other types, form
fields of another type, a required one missing, a value or hedge not found in the text, and a clause
that does not occur exactly once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph the record was applied to. |
required |
rubric
|
Rubric
|
The rubric. |
required |
record
|
Any
|
The record, as the model returned it. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
One instruction per problem found, in the record's order; empty when none is found. |
Source code in src/credencegraph_extract/assemble.py
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 | |
premises_rubric_problem(rubric)
¶
Say why a rubric cannot take premise records, or return None if it can.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rubric
|
Rubric
|
The rubric. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The problem: the rubric has no |
str | None
|
type for analyst nodes. |
Source code in src/credencegraph_extract/assemble.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
unlabelled(value)
¶
Return the id a model wrote with the label a listing shows it with, as s-2 of s-2 (result).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
What the model wrote where an id belongs. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The id before the label, or |
Source code in src/credencegraph_extract/assemble.py
427 428 429 430 431 432 433 434 435 436 437 | |