pyprocessors-coreference 1.6.32__tar.gz → 1.6.34__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/PKG-INFO +4 -2
  2. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/README.md +3 -1
  3. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/docs/sherpa/coreference.en.md +5 -5
  4. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/docs/sherpa/coreference.fr.md +5 -5
  5. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/src/pyprocessors_coreference/__init__.py +1 -1
  6. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/src/pyprocessors_coreference/coreference.py +19 -1
  7. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/.claude/settings.json +0 -0
  8. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/.gitignore +0 -0
  9. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/.gitmodules +0 -0
  10. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/.python-version +0 -0
  11. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/LICENSE +0 -0
  12. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/docs/adr/0001-linking-candidats-entityfishing-decision-jev.md +0 -0
  13. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/docs/adr/0002-acronymes-mentions-de-l-entite.md +0 -0
  14. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/pyproject.toml +0 -0
  15. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/.claude-plugin/marketplace.json +0 -0
  16. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/.claude-plugin/plugin.json +0 -0
  17. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/HOWTO.md +0 -0
  18. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/README.md +0 -0
  19. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/resources/Stages.yml +0 -0
  20. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/resources/help/help_examples.py +0 -0
  21. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/resources/help/plugin-help.py +0 -0
  22. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/resources/help/template.en.md +0 -0
  23. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/resources/help/template.fr.md +0 -0
  24. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/new-plugin/SKILL.md +0 -0
  25. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/new-plugin/references/annotator.md +0 -0
  26. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/new-plugin/references/converter.md +0 -0
  27. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/new-plugin/references/formatter.md +0 -0
  28. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/new-plugin/references/importer.md +0 -0
  29. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/new-plugin/references/processor.md +0 -0
  30. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/new-plugin/references/segmenter.md +0 -0
  31. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/new-plugin/references/types.md +0 -0
  32. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/skills/plugin-help/SKILL.md +0 -0
  33. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/tools/check-marketplace.py +0 -0
  34. {pyprocessors_coreference-1.6.32 → pyprocessors_coreference-1.6.34}/submodules/python-archetype/vars/pythonPipeline.groovy +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pyprocessors-coreference
3
- Version: 1.6.32
3
+ Version: 1.6.34
4
4
  Summary: Processor grouping the mentions of the same entity
5
5
  Project-URL: Homepage, https://bitbucket.org/kairntech/pyprocessors_coreference
6
6
  Author-email: Olivier Terrier <olivier.terrier@kairntech.com>
@@ -63,7 +63,9 @@ Pour chaque document, entre mentions de même famille de labels :
63
63
  - **un nom partiel de personne rejoint le nom complet dont il est la fin**, que le
64
64
  nom complet soit avant ou après lui dans le document : « Macron » et « M. Macron »
65
65
  rejoignent « Emmanuel Macron » ;
66
- - **un prénom seul ne rejoint jamais un nom complet** : « Emmanuel » reste à part ;
66
+ - **un prénom seul rejoint le seul nom complet qu'il commence** : « Emmanuel » rejoint
67
+ « Emmanuel Macron », sauf si une de ses mentions est incluse dans une mention plus longue
68
+ (un lexique qui reconnaît « Charles » dans « Charles White ») ;
67
69
  - **un nom partiel ambigu n'est pas fusionné** : avec « Emmanuel Macron » et
68
70
  « Brigitte Macron » dans le texte, « Macron » garde son propre groupe, et liste les
69
71
  groupes possibles pour que l'étape de linking tranche ;
@@ -33,7 +33,9 @@ Pour chaque document, entre mentions de même famille de labels :
33
33
  - **un nom partiel de personne rejoint le nom complet dont il est la fin**, que le
34
34
  nom complet soit avant ou après lui dans le document : « Macron » et « M. Macron »
35
35
  rejoignent « Emmanuel Macron » ;
36
- - **un prénom seul ne rejoint jamais un nom complet** : « Emmanuel » reste à part ;
36
+ - **un prénom seul rejoint le seul nom complet qu'il commence** : « Emmanuel » rejoint
37
+ « Emmanuel Macron », sauf si une de ses mentions est incluse dans une mention plus longue
38
+ (un lexique qui reconnaît « Charles » dans « Charles White ») ;
37
39
  - **un nom partiel ambigu n'est pas fusionné** : avec « Emmanuel Macron » et
38
40
  « Brigitte Macron » dans le texte, « Macron » garde son propre groupe, et liste les
39
41
  groupes possibles pour que l'étape de linking tranche ;
@@ -61,7 +61,7 @@ Two mentions go in the same group in the following cases:
61
61
 
62
62
  1. **Same form and same label family.** The comparison ignores case and apostrophe variants: "Airbus" and "AIRBUS" are grouped. A label whose name ends with another grouped label is of its family: a "Washington" annotated `location` by a model and `afplocation` by a lexicon forms a single group, as do `organization` and `afporganization`.
63
63
  2. **Same family of persons.** All person labels count as one, whatever their name: a "George Lucas" annotated `person` by a model and `afpperson` by a lexicon forms a single group.
64
- 3. **Partial name, for persons only.** A name that ends a longer name joins this name, whether it appears before or after it in the document: "Macron" and "M. Macron" join "Emmanuel Macron". The **Honorifics** titles are ignored for the comparison.
64
+ 3. **Partial name, for persons only.** A name that ends a longer name joins this name, whether it appears before or after it in the document: "Macron" and "M. Macron" join "Emmanuel Macron". The **Honorifics** titles are ignored for the comparison. A first name alone likewise joins the only full name it starts: "Emmanuel" joins "Emmanuel Macron".
65
65
  4. **Forms of one acronym.** When the Acronyms annotator ran before, the short form ("SEP") and the expanded form ("sclérose en plaques") of an acronym join the entity found exactly on one of them, everywhere in the document:
66
66
  - they take its label, the most frequent one if the entities of their forms have several;
67
67
  - a form already annotated by an entity is not duplicated: the acronym annotation is removed;
@@ -69,8 +69,8 @@ Two mentions go in the same group in the following cases:
69
69
 
70
70
  Are **never** grouped:
71
71
 
72
- - **a first name alone**: "Emmanuel" does not join "Emmanuel Macron", as it does not end the name;
73
- - **an ambiguous partial name**: with "Emmanuel Macron" and "Brigitte Macron" in the same document, "Macron" forms its own group. Its `entity_group_candidates` property lists the two possible groups, and the linking step decides;
72
+ - **a first name inside a longer mention**: a lexicon matching "Charles" within "Charles White" leaves "Charles" apart;
73
+ - **an ambiguous partial name**: with "Emmanuel Macron" and "Brigitte Macron" in the same document, "Macron" forms its own group, as does "Pierre" with "Pierre Curie" and "Pierre Dupont". Its `entity_group_candidates` property lists the two possible groups, and the linking step decides;
74
74
  - **different label families**, persons aside: the person "George Washington" and the place "Washington" stay separate;
75
75
  - **a partial name of an organization or a place**: "Airbus" does not join "Airbus Defence and Space".
76
76
 
@@ -80,7 +80,7 @@ In each example, the output table shows the properties added to each annotation.
80
80
 
81
81
  ### 1. A partial name joins the full name
82
82
 
83
- "M. Macron" joins "Emmanuel Macron": same group `g1`, same canonical form. The first name alone, "Emmanuel", forms its own group:
83
+ "M. Macron" and the first name alone, "Emmanuel", join "Emmanuel Macron": same group `g1`, same canonical form:
84
84
 
85
85
  <!-- generated:example:partial-name -->
86
86
 
@@ -104,7 +104,7 @@ Output annotations:
104
104
  |---|---|---|---|
105
105
  | Emmanuel Macron | `person` | 1.00 | `canonical_form`: Emmanuel Macron<br>`entity_group`: g1<br>`family`: person<br>`mention_type`: name |
106
106
  | M. Macron | `person` | 1.00 | `canonical_form`: Emmanuel Macron<br>`entity_group`: g1<br>`family`: person<br>`mention_type`: name |
107
- | Emmanuel | `person` | 1.00 | `canonical_form`: Emmanuel<br>`entity_group`: g2<br>`family`: person<br>`mention_type`: name |
107
+ | Emmanuel | `person` | 1.00 | `canonical_form`: Emmanuel Macron<br>`entity_group`: g1<br>`family`: person<br>`mention_type`: name |
108
108
 
109
109
  <!-- /generated:example:partial-name -->
110
110
 
@@ -61,7 +61,7 @@ Deux mentions vont dans le même groupe dans les cas suivants :
61
61
 
62
62
  1. **Même forme et même famille de labels.** La comparaison ignore les majuscules et les variantes d'apostrophe : « Airbus » et « AIRBUS » sont regroupés. Un label dont le nom finit par un autre label regroupé est de sa famille : un « Washington » annoté `location` par un modèle et `afplocation` par un lexique forme un seul groupe, comme `organization` et `afporganization`.
63
63
  2. **Même famille de personnes.** Tous les labels de personnes comptent comme un seul, quel que soit leur nom : un « George Lucas » annoté `person` par un modèle et `afpperson` par un lexique forme un seul groupe.
64
- 3. **Nom partiel, pour les personnes seulement.** Un nom qui termine un nom plus long rejoint ce nom, qu'il apparaisse avant ou après lui dans le document : « Macron » et « M. Macron » rejoignent « Emmanuel Macron ». Les civilités de **Honorifics** sont ignorées pour comparer.
64
+ 3. **Nom partiel, pour les personnes seulement.** Un nom qui termine un nom plus long rejoint ce nom, qu'il apparaisse avant ou après lui dans le document : « Macron » et « M. Macron » rejoignent « Emmanuel Macron ». Les civilités de **Honorifics** sont ignorées pour comparer. Un prénom seul rejoint de même le seul nom complet qu'il commence : « Emmanuel » rejoint « Emmanuel Macron ».
65
65
  4. **Formes d'un même acronyme.** Quand l'annotateur Acronymes est passé avant, la forme courte (« SEP ») et la forme développée (« sclérose en plaques ») d'un acronyme rejoignent l'entité trouvée exactement sur l'une d'elles, partout dans le document :
66
66
  - elles prennent son label, le plus fréquent si les entités de leurs formes en ont plusieurs ;
67
67
  - une forme déjà annotée par une entité n'est pas dupliquée : l'annotation de l'acronyme est retirée ;
@@ -69,8 +69,8 @@ Deux mentions vont dans le même groupe dans les cas suivants :
69
69
 
70
70
  Ne sont **jamais** regroupés :
71
71
 
72
- - **un prénom seul** : « Emmanuel » ne rejoint pas « Emmanuel Macron », car il ne termine pas le nom ;
73
- - **un nom partiel ambigu** : avec « Emmanuel Macron » et « Brigitte Macron » dans le même document, « Macron » forme son propre groupe. Sa propriété `entity_group_candidates` liste les deux groupes possibles, et c'est l'étape de liaison qui tranche ;
72
+ - **un prénom inclus dans une mention plus longue** : un lexique qui reconnaît « Charles » dans « Charles White » laisse « Charles » à part ;
73
+ - **un nom partiel ambigu** : avec « Emmanuel Macron » et « Brigitte Macron » dans le même document, « Macron » forme son propre groupe, comme « Pierre » avec « Pierre Curie » et « Pierre Dupont ». Sa propriété `entity_group_candidates` liste les deux groupes possibles, et c'est l'étape de liaison qui tranche ;
74
74
  - **des familles de labels différentes**, hors personnes : la personne « George Washington » et le lieu « Washington » restent séparés ;
75
75
  - **un nom partiel d'organisation ou de lieu** : « Airbus » ne rejoint pas « Airbus Defence and Space ».
76
76
 
@@ -80,7 +80,7 @@ Dans chaque exemple, le tableau de sortie montre les propriétés ajoutées à c
80
80
 
81
81
  ### 1. Un nom partiel rejoint le nom complet
82
82
 
83
- « M. Macron » rejoint « Emmanuel Macron » : même groupe `g1`, même forme canonique. Le prénom seul, « Emmanuel », forme son propre groupe :
83
+ « M. Macron » et le prénom seul « Emmanuel » rejoignent « Emmanuel Macron » : même groupe `g1`, même forme canonique :
84
84
 
85
85
  <!-- generated:example:partial-name -->
86
86
 
@@ -104,7 +104,7 @@ Annotations en sortie :
104
104
  |---|---|---|---|
105
105
  | Emmanuel Macron | `person` | 1,00 | `canonical_form` : Emmanuel Macron<br>`entity_group` : g1<br>`family` : person<br>`mention_type` : name |
106
106
  | M. Macron | `person` | 1,00 | `canonical_form` : Emmanuel Macron<br>`entity_group` : g1<br>`family` : person<br>`mention_type` : name |
107
- | Emmanuel | `person` | 1,00 | `canonical_form` : Emmanuel<br>`entity_group` : g2<br>`family` : person<br>`mention_type` : name |
107
+ | Emmanuel | `person` | 1,00 | `canonical_form` : Emmanuel Macron<br>`entity_group` : g1<br>`family` : person<br>`mention_type` : name |
108
108
 
109
109
  <!-- /generated:example:partial-name -->
110
110
 
@@ -1,3 +1,3 @@
1
1
  """Processor grouping the mentions of the same entity"""
2
2
 
3
- __version__ = "1.6.32"
3
+ __version__ = "1.6.34"
@@ -78,7 +78,8 @@ class CoreferenceProcessor(ProcessorBase):
78
78
  as one;
79
79
  - person labels only: a partial name joins the full name it ends, wherever the
80
80
  full name is in the document ("Macron" joins "Emmanuel Macron");
81
- - a first name alone never joins ("Emmanuel" stays on its own);
81
+ - a first name alone joins the only full name it starts ("Emmanuel" joins
82
+ "Emmanuel Macron"), unless one of its mentions lies inside a longer one;
82
83
  - an ambiguous partial name ("Macron" with both Emmanuel and Brigitte Macron)
83
84
  keeps a group of its own, and lists the possible groups in
84
85
  `entity_group_candidates` for the linking step to decide;
@@ -146,6 +147,23 @@ def group_document(document: Document, params: CoreferenceParameters, honorifics
146
147
  elif longer:
147
148
  ambiguous[key] = longer
148
149
 
150
+ # A first name alone, left by the suffix rule, joins the only full name it starts
151
+ # ("Cristiano" joins "Cristiano Ronaldo"), unless one of its mentions lies inside a
152
+ # longer one: a lexicon matching "Charles" within "Charles White".
153
+ persons = [a for key, annotations in surfaces.items() if key[0] == PERSON_FAMILY for a in annotations]
154
+ for key in surfaces:
155
+ family, tokens = key
156
+ if family != PERSON_FAMILY or len(tokens) != 1 or root(key) != key or key in ambiguous:
157
+ continue
158
+ if any(b.start <= a.start and a.end <= b.end and b.end - b.start > a.end - a.start for a in surfaces[key] for b in persons):
159
+ continue
160
+ longer = {root(other) for other in surfaces if other[0] == PERSON_FAMILY and len(other[1]) > 1 and other[1][0] == tokens[0]}
161
+ longer.discard(key)
162
+ if len(longer) == 1:
163
+ parent[key] = longer.pop()
164
+ elif longer:
165
+ ambiguous[key] = longer
166
+
149
167
  # 3. Ids in order of first appearance, canonical form = longest mention of the group.
150
168
  members: dict[tuple, list[Annotation]] = defaultdict(list)
151
169
  for key, annotations in surfaces.items():