@knaw-huc/text-annotation-segmenter 0.1.0 → 0.1.1
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.
- package/README.md +1 -1
- package/dist/Model.d.ts +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/segment.d.ts +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ However, HTML is hierarchical. How to display these kinds of annotations that do
|
|
|
11
11
|
|
|
12
12
|
The `segment` function creates an array of segments: a flat, non-overlapping list where each segment links to both the text and all the annotations that apply. Each segment translates into a single DOM element. Elements linked to multiple overlapping annotations can now be decorated with their own styling, classes and callbacks.
|
|
13
13
|
|
|
14
|
-
A special case is the marker: an annotation of zero width marking a position in the text. Markers result in zero-width segments, also linking all annotations that start at
|
|
14
|
+
A special case is the marker: an annotation of zero width marking a position in the text. Markers result in zero-width segments, also linking all annotations that start at or span across that position.
|
|
15
15
|
|
|
16
16
|
## API
|
|
17
17
|
|
package/dist/Model.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Input
|
|
2
|
+
* Input: object linking annotation to the text using character offsets.
|
|
3
3
|
*/
|
|
4
|
-
export type
|
|
4
|
+
export type AnnotationOffsets<T = unknown> = {
|
|
5
5
|
begin: number;
|
|
6
6
|
end: number;
|
|
7
7
|
body: T;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* Output
|
|
10
|
+
* Output: segment of text and the annotations that apply.
|
|
11
11
|
*/
|
|
12
12
|
export type TextSegment<T = unknown> = {
|
|
13
13
|
id: SegmentId;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { segment } from './segment.ts';
|
|
|
2
2
|
export type { AnnotationSegmentsByChar } from './segment.ts';
|
|
3
3
|
export { groupSegments } from './groupSegments.ts';
|
|
4
4
|
export type { Group } from './groupSegments.ts';
|
|
5
|
-
export type {
|
|
5
|
+
export type { AnnotationOffsets, TextSegment, SegmentId, } from './Model.ts';
|
package/dist/segment.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnnotationOffsets, TextSegment } from './Model';
|
|
2
2
|
/**
|
|
3
3
|
* Split a text into {@link TextSegment}s with character offsets and a list of applying annotations.
|
|
4
4
|
*/
|
|
5
|
-
export declare function segment<T>(text: string, annotations:
|
|
5
|
+
export declare function segment<T>(text: string, annotations: AnnotationOffsets<T>[]): TextSegment<T>[];
|
|
6
6
|
export type AnnotationSegmentsByChar<T = unknown> = {
|
|
7
7
|
charIndex: number;
|
|
8
|
-
starting:
|
|
9
|
-
ending:
|
|
8
|
+
starting: AnnotationOffsets<T>[];
|
|
9
|
+
ending: AnnotationOffsets<T>[];
|
|
10
10
|
};
|