@tricoteuses/tisseuse 0.14.18 → 0.15.0

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.
@@ -38,6 +38,7 @@ export type ActionOperation = (ActionOperationTarget & {
38
38
  targetText: string;
39
39
  insertText: string;
40
40
  insertLayout?: ActionInsertLayout;
41
+ occurrenceIndex?: number;
41
42
  citation?: ActionCitation;
42
43
  tableTarget?: ActionTableTarget;
43
44
  }) | (ActionOperationTarget & {
@@ -77,6 +78,7 @@ export type ResolvedActionDirective = (ActionDirectiveCommon & {
77
78
  targetText: string;
78
79
  insertText: string;
79
80
  insertLayout?: ActionInsertLayout;
81
+ occurrenceIndex?: number;
80
82
  citation?: ActionCitation;
81
83
  tableTarget?: ActionTableTarget;
82
84
  }) | (ActionDirectiveCommon & {
@@ -0,0 +1,17 @@
1
+ import { ResolvedActionDirective } from './action_directives.js';
2
+ import { FragmentPosition } from '../text_parsers/fragments.js';
3
+ export type ArticleActionSourceAnnotation = {
4
+ /** Offsets in the original block text, before parser simplification. */
5
+ sourceText: string;
6
+ referencePosition: FragmentPosition;
7
+ actionPosition: FragmentPosition;
8
+ };
9
+ export type ArticleActionEffect = {
10
+ targetId: string;
11
+ directive: ResolvedActionDirective;
12
+ sourceAnnotation: ArticleActionSourceAnnotation;
13
+ };
14
+ /** Source ranges for distinct operations on the same article, from the grammar. */
15
+ export declare function extractActionOperationSourceAnnotations(sourceText: string, operationCount: number): ArticleActionSourceAnnotation[] | null;
16
+ /** Resolve linked article targets only when the grammar accounts for every link. */
17
+ export declare function extractArticleActionEffects(sourceText: string, targetIds: string[]): ArticleActionEffect[] | null;
@@ -0,0 +1,11 @@
1
+ import { TextAstArticle, TextAstReference } from '../text_parsers/ast.js';
2
+ export type ArticleActionTarget = {
3
+ article: TextAstArticle;
4
+ reference: TextAstReference;
5
+ };
6
+ /**
7
+ * Split a parsed reference at article boundaries, keeping the portion tree
8
+ * attached to each article. A portion enumeration *inside* an article is
9
+ * deliberately kept together: it describes several edits to one article.
10
+ */
11
+ export declare function extractArticleActionTargets(reference: TextAstReference): ArticleActionTarget[];
@@ -1,5 +1,7 @@
1
+ import { FrenchCitationParseOptions } from '../text_parsers/citations.js';
1
2
  import { FragmentPosition } from '../text_parsers/fragments.js';
2
3
  export type QuotedTextInfo = {
4
+ closed?: boolean;
3
5
  text: string;
4
6
  start: number;
5
7
  end: number;
@@ -9,7 +11,7 @@ export type QuoteRange = {
9
11
  end: number;
10
12
  };
11
13
  export declare function normalizeQuotedText(text: string): string;
12
- export declare function extractQuotedTextInfos(text: string): QuotedTextInfo[];
14
+ export declare function extractQuotedTextInfos(text: string, options?: FrenchCitationParseOptions): QuotedTextInfo[];
13
15
  export declare function stripQuotedTextSegments(text: string, quotedInfos: Pick<QuotedTextInfo, "start" | "end">[]): string;
14
16
  export declare function getQuoteRanges(text: string): QuoteRange[];
15
17
  export declare function isInsideRanges(position: FragmentPosition | undefined, ranges: Array<{
@@ -26,7 +26,7 @@ export { action } from './text_parsers/actions.js';
26
26
  export { actionDirective } from './text_parsers/action_directives.js';
27
27
  export { article, articles, definitionArticleDansCitation, definitionArticleDansProjetOuPropositionLoi, designationArticle, extractArticleDefinitionsFromCitation, listeArticles, nomArticle, normalizeBillArticleNumber, parseArticleNumber, parseBillArticleLabel, type ArticleDefinitionInCitation, nomSpecialArticle, type BillArticleLabel, } from './text_parsers/articles.js';
28
28
  export { actionTargets, compoundReferencesSeparators, divisionTypes, europeanLawNatures, frenchLawNatures, internationalLawNatures, isTextAstAtomicReference, isTextAstDivision, isTextAstPortion, lawNatures, localizationAdverbs, portionTypes, type ActionTarget, type CompoundReferencesSeparator, type DivisionType, type EuropeanLawNature, type FrenchLawNature, type InternationalLawNature, type LawNature, type LocalizationAdverb, type PortionType, type TextAst, type TextAstAction, type TextAstActionDirective, type TextAstActionDirectiveOperation, type TextAstActionTargetScope, type TextAstApplicabilityClause, type TextAstArticle, type TextAstAtomicReference, type TextAstBoundedInterval, type TextAstCitation, type TextAstCompoundReference, type TextAstConseilConstitutionnelDecision, type TextAstCountedInterval, type TextAstDivision, type TextAstEnumeration, type TextAstExclusion, type TextAstIncompleteHeader, type TextAstLocalization, type TextAstModificationBlock, type TextAstModificationItem, type TextAstNumber, type TextAstParentChild, type TextAstPortion, type TextAstPosition, type TextAstReference, type TextAstReferenceAndAction, type TextAstText, type TextAstTextIdentification, type TextAstTextInfos, type TextInfosByWordsTree, type TextInfosByWordsTreeNode, } from './text_parsers/ast.js';
29
- export { citation, citationToText, citationLigne, citationSimple, } from './text_parsers/citations.js';
29
+ export { citation, citationToText, citationLigne, citationSimple, extractFrenchCitations, parseFrenchCitationAt, type FrenchCitationParseOptions, type ParsedFrenchCitation, } from './text_parsers/citations.js';
30
30
  export { date, duDate } from './text_parsers/dates.js';
31
31
  export { referenceDoctrinale, referenceDoctrinaleArticleAvantSource, referenceDoctrinaleArticlesAvantSource, referenceDoctrinaleSourceAvantArticle, } from './text_parsers/doctrinal_references.js';
32
32
  export { definitionDivision, designationDivision, division, divisions, natureDivisionSingulier, numeroDivision, } from './text_parsers/divisions.js';
@@ -1,13 +1,15 @@
1
1
  import { Sql } from 'postgres';
2
2
  import { ResolvedActionDirective } from '../extractors/action_directives.js';
3
+ import { ArticleActionEffect, ArticleActionSourceAnnotation } from '../extractors/article_action_effects.js';
3
4
  import { TableOfContents } from '../extractors/table_of_contents.js';
4
5
  import { LegiResolver } from '../legi/resolver.js';
5
6
  import { LinkType } from '../links.js';
6
7
  export type ParsedBillSourceFormat = "assemblee-html" | "akoma-ntoso";
7
8
  export type ParsedBillBlockKind = "directive_candidate" | "context" | "noise";
8
9
  export type ParsedBillToc = TableOfContents;
10
+ export type ParsedBillDiagnosticCode = "nested_french_quote_in_redaction" | "assemblee_toc_article_order_mismatch" | "article_toc_number_gap" | "article_toc_out_of_order" | "article_toc_duplicate_number" | "article_toc_missing_anchor" | "article_toc_source_heading_mismatch";
9
11
  export type ParsedBillDiagnostic = {
10
- code: string;
12
+ code: ParsedBillDiagnosticCode;
11
13
  message: string;
12
14
  details?: unknown;
13
15
  };
@@ -66,6 +68,10 @@ export type ParsedBillDirective = {
66
68
  stop: number;
67
69
  };
68
70
  directive: ResolvedActionDirective;
71
+ /** Per-article effects when the source modifies several linked articles. */
72
+ effects?: ArticleActionEffect[];
73
+ /** Grammar positions of separate operations modifying the same article. */
74
+ sourceAnnotations?: ArticleActionSourceAnnotation[];
69
75
  createdArticle?: ParsedBillInternalArticleTarget;
70
76
  createdArticles?: ParsedBillInternalArticleTarget[];
71
77
  internalTarget?: ParsedBillInternalArticleTarget & {
@@ -47,8 +47,10 @@ export declare const nomArticleDefinition: import('./parsers.js').TextParser<imp
47
47
  *
48
48
  * Dans un projet (ou une proposition) de loi initial, un numéro d'article
49
49
  * est un simple nombre ou un nom spécial.
50
- * Dans les versions suivantes, le numéro d'article est un nombre éventuellement
51
- * suivi d'un adverbe multiplicatif latin.
50
+ * Dans les versions suivantes, le numéro d'article peut aussi être suivi
51
+ * d'une lettre (article 1 A) ou d'un adverbe latin et de lettres (3 bis AA).
52
+ * Cette règle reste distincte de nomArticle : les références aux articles
53
+ * de codes peuvent avoir un préfixe et des séparateurs absents des PJL/PPL.
52
54
  */
53
55
  export declare const nomArticleProjetOuPropositionLoi: import('./parsers.js').TextParser<import('./ast.js').TextAst>;
54
56
  /**
@@ -1,11 +1,28 @@
1
- import { TextAst, TextAstCitation } from './ast.js';
1
+ import { TextAstCitation } from './ast.js';
2
2
  import { TextParserContext, TextParser } from './parsers.js';
3
3
  import { TransformationLeaf } from './transformers.js';
4
4
  type TextAstPositionRange = TextAstCitation["position"];
5
5
  export declare function createTextAstCitation(contentPosition: TextAstPositionRange, position?: TextAstPositionRange): TextAstCitation;
6
- export declare const citationLigne: TextParser<TextAst>;
7
- export declare const citationSimple: TextParser<TextAst>;
8
- export declare const citation: TextParser<TextAst>;
6
+ export type FrenchCitationParseOptions = {
7
+ allowClosingQuoteAsOpening?: boolean;
8
+ allowUnclosed?: boolean;
9
+ };
10
+ export type ParsedFrenchCitation = {
11
+ closed: boolean;
12
+ content: Array<{
13
+ start: number;
14
+ stop: number;
15
+ }>;
16
+ position: {
17
+ start: number;
18
+ stop: number;
19
+ };
20
+ };
21
+ export declare const citationLigne: TextParser<import('./ast.js').TextAst>;
22
+ export declare const citationSimple: TextParser<import('./ast.js').TextAst>;
23
+ export declare function parseFrenchCitationAt(input: string, start: number, { allowClosingQuoteAsOpening, allowUnclosed, }?: FrenchCitationParseOptions): ParsedFrenchCitation | undefined;
24
+ export declare function extractFrenchCitations(input: string, options?: FrenchCitationParseOptions): ParsedFrenchCitation[];
25
+ export declare const citation: TextParser<TextAstCitation>;
9
26
  export declare function convertCitationToText(context: TextParserContext, citation: TextAstCitation): TransformationLeaf;
10
27
  export declare function citationToText(sourceText: string, citation: TextAstCitation): string;
11
28
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tricoteuses/tisseuse",
3
3
  "description": "Find links in/to French legislative documents",
4
- "version": "0.14.18",
4
+ "version": "0.15.0",
5
5
  "keywords": [
6
6
  "Assemblée nationale",
7
7
  "France",