@internetarchive/radio-player 0.0.4-alpha.1 → 0.1.1-alpha.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/LICENSE +661 -661
- package/README.md +142 -142
- package/index.d.ts +15 -15
- package/index.js +28 -28
- package/lib/src/assets/img/left.d.ts +2 -2
- package/lib/src/assets/img/left.js +15 -15
- package/lib/src/assets/img/right.d.ts +2 -2
- package/lib/src/assets/img/right.js +15 -15
- package/lib/src/models/music-zone.d.ts +12 -12
- package/lib/src/models/music-zone.js +15 -15
- package/lib/src/models/radio-player-config.d.ts +26 -26
- package/lib/src/models/radio-player-config.js +27 -27
- package/lib/src/radio-player.d.ts +589 -589
- package/lib/src/radio-player.js +1337 -1338
- package/lib/src/radio-player.js.map +1 -1
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.d.ts +82 -82
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.js +107 -107
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-delegate.d.ts +9 -0
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-delegate.js +1 -0
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-delegate.js.map +1 -0
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.d.ts +48 -48
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.js +58 -58
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.d.ts +16 -16
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.js +1 -1
- package/lib/src/search-handler/search-backends/local-search-backend/local-search-backend.d.ts +27 -27
- package/lib/src/search-handler/search-backends/local-search-backend/local-search-backend.js +42 -42
- package/lib/src/search-handler/search-backends/search-backend-interface.d.ts +9 -9
- package/lib/src/search-handler/search-backends/search-backend-interface.js +1 -1
- package/lib/src/search-handler/search-handler-interface.d.ts +17 -17
- package/lib/src/search-handler/search-handler-interface.js +1 -1
- package/lib/src/search-handler/search-handler.d.ts +83 -83
- package/lib/src/search-handler/search-handler.js +177 -177
- package/lib/src/search-handler/search-helper.d.ts +12 -12
- package/lib/src/search-handler/search-helper.js +22 -22
- package/lib/src/search-handler/search-index.d.ts +53 -0
- package/lib/src/search-handler/search-index.js +118 -0
- package/lib/src/search-handler/search-index.js.map +1 -0
- package/lib/src/search-handler/search-models.d.ts +45 -45
- package/lib/src/search-handler/search-models.js +49 -49
- package/lib/src/search-handler/transcript-index-interface.d.ts +38 -38
- package/lib/src/search-handler/transcript-index-interface.js +1 -1
- package/lib/src/search-handler/transcript-index.d.ts +53 -53
- package/lib/src/search-handler/transcript-index.js +80 -80
- package/lib/src/search-results-switcher.d.ts +58 -58
- package/lib/src/search-results-switcher.js +133 -133
- package/package.json +93 -93
- package/src/assets/img/left.ts +17 -17
- package/src/assets/img/right.ts +17 -17
- package/src/models/music-zone.ts +17 -17
- package/src/models/radio-player-config.ts +47 -47
- package/src/radio-player.ts +1398 -1402
- package/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.ts +140 -140
- package/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.ts +110 -110
- package/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.ts +17 -17
- package/src/search-handler/search-backends/local-search-backend/local-search-backend.ts +50 -50
- package/src/search-handler/search-backends/search-backend-interface.ts +10 -10
- package/src/search-handler/search-handler-interface.ts +18 -18
- package/src/search-handler/search-handler.ts +217 -217
- package/src/search-handler/search-helper.ts +25 -25
- package/src/search-handler/search-models.ts +69 -69
- package/src/search-handler/transcript-index-interface.ts +42 -42
- package/src/search-handler/transcript-index.ts +93 -93
- package/src/search-results-switcher.ts +131 -131
- package/lib/demo/full-text-search-service.d.ts +0 -14
- package/lib/demo/full-text-search-service.js +0 -34
- package/lib/demo/full-text-search-service.js.map +0 -1
- package/lib/demo/radio-player-controller.d.ts +0 -41
- package/lib/demo/radio-player-controller.js +0 -200
- package/lib/demo/radio-player-controller.js.map +0 -1
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { TranscriptEntryConfig } from '@internetarchive/transcript-view';
|
|
2
|
-
/**
|
|
3
|
-
* A model to store the start and end indices for a given context.
|
|
4
|
-
* This is used for augmenting the source transcript entries (`TranscriptEntryRange`)
|
|
5
|
-
* as well as the search result entries (`SearchResult`) below.
|
|
6
|
-
*
|
|
7
|
-
* @class Range
|
|
8
|
-
*/
|
|
9
|
-
declare class Range {
|
|
10
|
-
startIndex: number;
|
|
11
|
-
endIndex: number;
|
|
12
|
-
get length(): number;
|
|
13
|
-
constructor(startIndex: number, endIndex: number);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* This class augments the transcript entry with the range of the characters
|
|
17
|
-
* in the merged transcript. This is useful for more rapidly splitting up and
|
|
18
|
-
* restoring the transcript entries from the transforms that happen during the search.
|
|
19
|
-
*
|
|
20
|
-
* @class TranscriptIndexMap
|
|
21
|
-
*/
|
|
22
|
-
declare class TranscriptEntryRange {
|
|
23
|
-
entry: TranscriptEntryConfig;
|
|
24
|
-
range: Range;
|
|
25
|
-
constructor(entry: TranscriptEntryConfig, range: Range);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The first step in converting the search results back to a usable transcript
|
|
29
|
-
* is to break up the overall merged transcript into search results and non-search-results
|
|
30
|
-
* sections. This will allow us to more easily break it up into its original transcript
|
|
31
|
-
* chunks in a subsequent process.
|
|
32
|
-
*
|
|
33
|
-
* This class is a container to hold those chunks. They each have a start and end index
|
|
34
|
-
* from their spot in the merged transcript, the text from that chunk, and whether that
|
|
35
|
-
* chunk was a search match or just regular text.
|
|
36
|
-
*
|
|
37
|
-
* @class SearchSeparatedTranscriptEntry
|
|
38
|
-
*/
|
|
39
|
-
declare class SearchResult {
|
|
40
|
-
range: Range;
|
|
41
|
-
text: string;
|
|
42
|
-
isSearchMatch: boolean;
|
|
43
|
-
constructor(range: Range, text: string, isSearchMatch: boolean);
|
|
44
|
-
}
|
|
45
|
-
export { Range, TranscriptEntryRange, SearchResult };
|
|
1
|
+
import { TranscriptEntryConfig } from '@internetarchive/transcript-view';
|
|
2
|
+
/**
|
|
3
|
+
* A model to store the start and end indices for a given context.
|
|
4
|
+
* This is used for augmenting the source transcript entries (`TranscriptEntryRange`)
|
|
5
|
+
* as well as the search result entries (`SearchResult`) below.
|
|
6
|
+
*
|
|
7
|
+
* @class Range
|
|
8
|
+
*/
|
|
9
|
+
declare class Range {
|
|
10
|
+
startIndex: number;
|
|
11
|
+
endIndex: number;
|
|
12
|
+
get length(): number;
|
|
13
|
+
constructor(startIndex: number, endIndex: number);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* This class augments the transcript entry with the range of the characters
|
|
17
|
+
* in the merged transcript. This is useful for more rapidly splitting up and
|
|
18
|
+
* restoring the transcript entries from the transforms that happen during the search.
|
|
19
|
+
*
|
|
20
|
+
* @class TranscriptIndexMap
|
|
21
|
+
*/
|
|
22
|
+
declare class TranscriptEntryRange {
|
|
23
|
+
entry: TranscriptEntryConfig;
|
|
24
|
+
range: Range;
|
|
25
|
+
constructor(entry: TranscriptEntryConfig, range: Range);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The first step in converting the search results back to a usable transcript
|
|
29
|
+
* is to break up the overall merged transcript into search results and non-search-results
|
|
30
|
+
* sections. This will allow us to more easily break it up into its original transcript
|
|
31
|
+
* chunks in a subsequent process.
|
|
32
|
+
*
|
|
33
|
+
* This class is a container to hold those chunks. They each have a start and end index
|
|
34
|
+
* from their spot in the merged transcript, the text from that chunk, and whether that
|
|
35
|
+
* chunk was a search match or just regular text.
|
|
36
|
+
*
|
|
37
|
+
* @class SearchSeparatedTranscriptEntry
|
|
38
|
+
*/
|
|
39
|
+
declare class SearchResult {
|
|
40
|
+
range: Range;
|
|
41
|
+
text: string;
|
|
42
|
+
isSearchMatch: boolean;
|
|
43
|
+
constructor(range: Range, text: string, isSearchMatch: boolean);
|
|
44
|
+
}
|
|
45
|
+
export { Range, TranscriptEntryRange, SearchResult };
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A model to store the start and end indices for a given context.
|
|
3
|
-
* This is used for augmenting the source transcript entries (`TranscriptEntryRange`)
|
|
4
|
-
* as well as the search result entries (`SearchResult`) below.
|
|
5
|
-
*
|
|
6
|
-
* @class Range
|
|
7
|
-
*/
|
|
8
|
-
class Range {
|
|
9
|
-
constructor(startIndex, endIndex) {
|
|
10
|
-
this.startIndex = startIndex;
|
|
11
|
-
this.endIndex = endIndex;
|
|
12
|
-
}
|
|
13
|
-
get length() {
|
|
14
|
-
return Math.abs(this.endIndex - this.startIndex);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* This class augments the transcript entry with the range of the characters
|
|
19
|
-
* in the merged transcript. This is useful for more rapidly splitting up and
|
|
20
|
-
* restoring the transcript entries from the transforms that happen during the search.
|
|
21
|
-
*
|
|
22
|
-
* @class TranscriptIndexMap
|
|
23
|
-
*/
|
|
24
|
-
class TranscriptEntryRange {
|
|
25
|
-
constructor(entry, range) {
|
|
26
|
-
this.entry = entry;
|
|
27
|
-
this.range = range;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The first step in converting the search results back to a usable transcript
|
|
32
|
-
* is to break up the overall merged transcript into search results and non-search-results
|
|
33
|
-
* sections. This will allow us to more easily break it up into its original transcript
|
|
34
|
-
* chunks in a subsequent process.
|
|
35
|
-
*
|
|
36
|
-
* This class is a container to hold those chunks. They each have a start and end index
|
|
37
|
-
* from their spot in the merged transcript, the text from that chunk, and whether that
|
|
38
|
-
* chunk was a search match or just regular text.
|
|
39
|
-
*
|
|
40
|
-
* @class SearchSeparatedTranscriptEntry
|
|
41
|
-
*/
|
|
42
|
-
class SearchResult {
|
|
43
|
-
constructor(range, text, isSearchMatch) {
|
|
44
|
-
this.range = range;
|
|
45
|
-
this.text = text;
|
|
46
|
-
this.isSearchMatch = isSearchMatch;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export { Range, TranscriptEntryRange, SearchResult };
|
|
1
|
+
/**
|
|
2
|
+
* A model to store the start and end indices for a given context.
|
|
3
|
+
* This is used for augmenting the source transcript entries (`TranscriptEntryRange`)
|
|
4
|
+
* as well as the search result entries (`SearchResult`) below.
|
|
5
|
+
*
|
|
6
|
+
* @class Range
|
|
7
|
+
*/
|
|
8
|
+
class Range {
|
|
9
|
+
constructor(startIndex, endIndex) {
|
|
10
|
+
this.startIndex = startIndex;
|
|
11
|
+
this.endIndex = endIndex;
|
|
12
|
+
}
|
|
13
|
+
get length() {
|
|
14
|
+
return Math.abs(this.endIndex - this.startIndex);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* This class augments the transcript entry with the range of the characters
|
|
19
|
+
* in the merged transcript. This is useful for more rapidly splitting up and
|
|
20
|
+
* restoring the transcript entries from the transforms that happen during the search.
|
|
21
|
+
*
|
|
22
|
+
* @class TranscriptIndexMap
|
|
23
|
+
*/
|
|
24
|
+
class TranscriptEntryRange {
|
|
25
|
+
constructor(entry, range) {
|
|
26
|
+
this.entry = entry;
|
|
27
|
+
this.range = range;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The first step in converting the search results back to a usable transcript
|
|
32
|
+
* is to break up the overall merged transcript into search results and non-search-results
|
|
33
|
+
* sections. This will allow us to more easily break it up into its original transcript
|
|
34
|
+
* chunks in a subsequent process.
|
|
35
|
+
*
|
|
36
|
+
* This class is a container to hold those chunks. They each have a start and end index
|
|
37
|
+
* from their spot in the merged transcript, the text from that chunk, and whether that
|
|
38
|
+
* chunk was a search match or just regular text.
|
|
39
|
+
*
|
|
40
|
+
* @class SearchSeparatedTranscriptEntry
|
|
41
|
+
*/
|
|
42
|
+
class SearchResult {
|
|
43
|
+
constructor(range, text, isSearchMatch) {
|
|
44
|
+
this.range = range;
|
|
45
|
+
this.text = text;
|
|
46
|
+
this.isSearchMatch = isSearchMatch;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export { Range, TranscriptEntryRange, SearchResult };
|
|
50
50
|
//# sourceMappingURL=search-models.js.map
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { TranscriptEntryRange } from './search-models';
|
|
2
|
-
/**
|
|
3
|
-
* The TranscriptIndexInterface defines methods needed to access and rebuild the transcript.
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @interface TranscriptIndexInterface
|
|
7
|
-
*/
|
|
8
|
-
export interface TranscriptIndexInterface {
|
|
9
|
-
/**
|
|
10
|
-
* The merged transcript, combining all entries with a single space
|
|
11
|
-
*
|
|
12
|
-
* @type {string}
|
|
13
|
-
* @memberof TranscriptIndexInterface
|
|
14
|
-
*/
|
|
15
|
-
mergedTranscript: string;
|
|
16
|
-
/**
|
|
17
|
-
* The merged transcript lowercased for case-insensitive lookups
|
|
18
|
-
*
|
|
19
|
-
* @type {string}
|
|
20
|
-
* @memberof TranscriptIndexInterface
|
|
21
|
-
*/
|
|
22
|
-
mergedTranscriptLowercased: string;
|
|
23
|
-
/**
|
|
24
|
-
* An array of transcript entries with their associated character ranges
|
|
25
|
-
*
|
|
26
|
-
* @type {TranscriptEntryRange[]}
|
|
27
|
-
* @memberof TranscriptIndexInterface
|
|
28
|
-
*/
|
|
29
|
-
transcriptEntryRanges: TranscriptEntryRange[];
|
|
30
|
-
/**
|
|
31
|
-
* Get the TranscriptEntryRange at a given index
|
|
32
|
-
*
|
|
33
|
-
* @param {number} overallCharIndex
|
|
34
|
-
* @returns {(TranscriptEntryRange | undefined)}
|
|
35
|
-
* @memberof TranscriptIndexInterface
|
|
36
|
-
*/
|
|
37
|
-
getTranscriptEntryAt(overallCharIndex: number): TranscriptEntryRange | undefined;
|
|
38
|
-
}
|
|
1
|
+
import { TranscriptEntryRange } from './search-models';
|
|
2
|
+
/**
|
|
3
|
+
* The TranscriptIndexInterface defines methods needed to access and rebuild the transcript.
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @interface TranscriptIndexInterface
|
|
7
|
+
*/
|
|
8
|
+
export interface TranscriptIndexInterface {
|
|
9
|
+
/**
|
|
10
|
+
* The merged transcript, combining all entries with a single space
|
|
11
|
+
*
|
|
12
|
+
* @type {string}
|
|
13
|
+
* @memberof TranscriptIndexInterface
|
|
14
|
+
*/
|
|
15
|
+
mergedTranscript: string;
|
|
16
|
+
/**
|
|
17
|
+
* The merged transcript lowercased for case-insensitive lookups
|
|
18
|
+
*
|
|
19
|
+
* @type {string}
|
|
20
|
+
* @memberof TranscriptIndexInterface
|
|
21
|
+
*/
|
|
22
|
+
mergedTranscriptLowercased: string;
|
|
23
|
+
/**
|
|
24
|
+
* An array of transcript entries with their associated character ranges
|
|
25
|
+
*
|
|
26
|
+
* @type {TranscriptEntryRange[]}
|
|
27
|
+
* @memberof TranscriptIndexInterface
|
|
28
|
+
*/
|
|
29
|
+
transcriptEntryRanges: TranscriptEntryRange[];
|
|
30
|
+
/**
|
|
31
|
+
* Get the TranscriptEntryRange at a given index
|
|
32
|
+
*
|
|
33
|
+
* @param {number} overallCharIndex
|
|
34
|
+
* @returns {(TranscriptEntryRange | undefined)}
|
|
35
|
+
* @memberof TranscriptIndexInterface
|
|
36
|
+
*/
|
|
37
|
+
getTranscriptEntryAt(overallCharIndex: number): TranscriptEntryRange | undefined;
|
|
38
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=transcript-index-interface.js.map
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { TranscriptConfig } from '@internetarchive/transcript-view';
|
|
2
|
-
import { TranscriptEntryRange } from './search-models';
|
|
3
|
-
import { TranscriptIndexInterface } from './transcript-index-interface';
|
|
4
|
-
/**
|
|
5
|
-
* The TranscriptIndex takes the original transcript and indexes it to make
|
|
6
|
-
* transcript entry lookups more efficient.
|
|
7
|
-
*/
|
|
8
|
-
export declare class TranscriptIndex implements TranscriptIndexInterface {
|
|
9
|
-
/** @inheritdoc */
|
|
10
|
-
get mergedTranscript(): string;
|
|
11
|
-
/** @inheritdoc */
|
|
12
|
-
get mergedTranscriptLowercased(): string;
|
|
13
|
-
/** @inheritdoc */
|
|
14
|
-
get transcriptEntryRanges(): TranscriptEntryRange[];
|
|
15
|
-
/** @inheritdoc */
|
|
16
|
-
getTranscriptEntryAt(overallCharIndex: number): TranscriptEntryRange | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* This gets populated as part of the search index build. It merges all of the transcript
|
|
19
|
-
* entries together so we can search it as a single document instead of a bunch of
|
|
20
|
-
* individual entries. This allows searches to cross over transcript entries.
|
|
21
|
-
*
|
|
22
|
-
* NOTE: When the mergedTranscript gets created, spaces are put between each transcript
|
|
23
|
-
* entry, otherwise the words would run into each other. We account for this in the
|
|
24
|
-
* indices above.
|
|
25
|
-
*
|
|
26
|
-
* @type {string}
|
|
27
|
-
* @memberof TranscriptIndex
|
|
28
|
-
*/
|
|
29
|
-
private mergedTranscriptCache;
|
|
30
|
-
private mergedTranscriptLowercasedCache;
|
|
31
|
-
/**
|
|
32
|
-
* This gets populated as part of the search index build. It maps the start and end indicies
|
|
33
|
-
* of all of the transcript entries so we can quickly look up where an entry is in the
|
|
34
|
-
* overall transcript.
|
|
35
|
-
*
|
|
36
|
-
* @type {TranscriptEntryRange[]}
|
|
37
|
-
* @memberof TranscriptIndex
|
|
38
|
-
*/
|
|
39
|
-
private transcriptEntryRangesCache;
|
|
40
|
-
constructor(transcriptConfig: TranscriptConfig);
|
|
41
|
-
/**
|
|
42
|
-
* Build the search index. This method does two things:
|
|
43
|
-
* 1. Builds the "merged transcript" with all of the text combined into one long transcript.
|
|
44
|
-
* This allows us to search the entire thing at once instead of entry by entry.
|
|
45
|
-
* 2. For each entry, get the start and end index of that particular entry within the overall
|
|
46
|
-
* transcript. This allows us to reconstruct the transcript later from the original transcript
|
|
47
|
-
* and the search results.
|
|
48
|
-
*
|
|
49
|
-
* @private
|
|
50
|
-
* @memberof TranscriptIndex
|
|
51
|
-
*/
|
|
52
|
-
private buildIndex;
|
|
53
|
-
}
|
|
1
|
+
import { TranscriptConfig } from '@internetarchive/transcript-view';
|
|
2
|
+
import { TranscriptEntryRange } from './search-models';
|
|
3
|
+
import { TranscriptIndexInterface } from './transcript-index-interface';
|
|
4
|
+
/**
|
|
5
|
+
* The TranscriptIndex takes the original transcript and indexes it to make
|
|
6
|
+
* transcript entry lookups more efficient.
|
|
7
|
+
*/
|
|
8
|
+
export declare class TranscriptIndex implements TranscriptIndexInterface {
|
|
9
|
+
/** @inheritdoc */
|
|
10
|
+
get mergedTranscript(): string;
|
|
11
|
+
/** @inheritdoc */
|
|
12
|
+
get mergedTranscriptLowercased(): string;
|
|
13
|
+
/** @inheritdoc */
|
|
14
|
+
get transcriptEntryRanges(): TranscriptEntryRange[];
|
|
15
|
+
/** @inheritdoc */
|
|
16
|
+
getTranscriptEntryAt(overallCharIndex: number): TranscriptEntryRange | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* This gets populated as part of the search index build. It merges all of the transcript
|
|
19
|
+
* entries together so we can search it as a single document instead of a bunch of
|
|
20
|
+
* individual entries. This allows searches to cross over transcript entries.
|
|
21
|
+
*
|
|
22
|
+
* NOTE: When the mergedTranscript gets created, spaces are put between each transcript
|
|
23
|
+
* entry, otherwise the words would run into each other. We account for this in the
|
|
24
|
+
* indices above.
|
|
25
|
+
*
|
|
26
|
+
* @type {string}
|
|
27
|
+
* @memberof TranscriptIndex
|
|
28
|
+
*/
|
|
29
|
+
private mergedTranscriptCache;
|
|
30
|
+
private mergedTranscriptLowercasedCache;
|
|
31
|
+
/**
|
|
32
|
+
* This gets populated as part of the search index build. It maps the start and end indicies
|
|
33
|
+
* of all of the transcript entries so we can quickly look up where an entry is in the
|
|
34
|
+
* overall transcript.
|
|
35
|
+
*
|
|
36
|
+
* @type {TranscriptEntryRange[]}
|
|
37
|
+
* @memberof TranscriptIndex
|
|
38
|
+
*/
|
|
39
|
+
private transcriptEntryRangesCache;
|
|
40
|
+
constructor(transcriptConfig: TranscriptConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Build the search index. This method does two things:
|
|
43
|
+
* 1. Builds the "merged transcript" with all of the text combined into one long transcript.
|
|
44
|
+
* This allows us to search the entire thing at once instead of entry by entry.
|
|
45
|
+
* 2. For each entry, get the start and end index of that particular entry within the overall
|
|
46
|
+
* transcript. This allows us to reconstruct the transcript later from the original transcript
|
|
47
|
+
* and the search results.
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
* @memberof TranscriptIndex
|
|
51
|
+
*/
|
|
52
|
+
private buildIndex;
|
|
53
|
+
}
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { Range, TranscriptEntryRange } from './search-models';
|
|
2
|
-
/**
|
|
3
|
-
* The TranscriptIndex takes the original transcript and indexes it to make
|
|
4
|
-
* transcript entry lookups more efficient.
|
|
5
|
-
*/
|
|
6
|
-
export class TranscriptIndex {
|
|
7
|
-
constructor(transcriptConfig) {
|
|
8
|
-
/**
|
|
9
|
-
* This gets populated as part of the search index build. It merges all of the transcript
|
|
10
|
-
* entries together so we can search it as a single document instead of a bunch of
|
|
11
|
-
* individual entries. This allows searches to cross over transcript entries.
|
|
12
|
-
*
|
|
13
|
-
* NOTE: When the mergedTranscript gets created, spaces are put between each transcript
|
|
14
|
-
* entry, otherwise the words would run into each other. We account for this in the
|
|
15
|
-
* indices above.
|
|
16
|
-
*
|
|
17
|
-
* @type {string}
|
|
18
|
-
* @memberof TranscriptIndex
|
|
19
|
-
*/
|
|
20
|
-
this.mergedTranscriptCache = '';
|
|
21
|
-
this.mergedTranscriptLowercasedCache = '';
|
|
22
|
-
/**
|
|
23
|
-
* This gets populated as part of the search index build. It maps the start and end indicies
|
|
24
|
-
* of all of the transcript entries so we can quickly look up where an entry is in the
|
|
25
|
-
* overall transcript.
|
|
26
|
-
*
|
|
27
|
-
* @type {TranscriptEntryRange[]}
|
|
28
|
-
* @memberof TranscriptIndex
|
|
29
|
-
*/
|
|
30
|
-
this.transcriptEntryRangesCache = [];
|
|
31
|
-
this.buildIndex(transcriptConfig);
|
|
32
|
-
}
|
|
33
|
-
/** @inheritdoc */
|
|
34
|
-
get mergedTranscript() {
|
|
35
|
-
return this.mergedTranscriptCache;
|
|
36
|
-
}
|
|
37
|
-
/** @inheritdoc */
|
|
38
|
-
get mergedTranscriptLowercased() {
|
|
39
|
-
return this.mergedTranscriptLowercasedCache;
|
|
40
|
-
}
|
|
41
|
-
/** @inheritdoc */
|
|
42
|
-
get transcriptEntryRanges() {
|
|
43
|
-
return this.transcriptEntryRangesCache;
|
|
44
|
-
}
|
|
45
|
-
/** @inheritdoc */
|
|
46
|
-
getTranscriptEntryAt(overallCharIndex) {
|
|
47
|
-
return this.transcriptEntryRanges.find((entry) => {
|
|
48
|
-
const { range } = entry;
|
|
49
|
-
return range.endIndex > overallCharIndex && range.startIndex <= overallCharIndex;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Build the search index. This method does two things:
|
|
54
|
-
* 1. Builds the "merged transcript" with all of the text combined into one long transcript.
|
|
55
|
-
* This allows us to search the entire thing at once instead of entry by entry.
|
|
56
|
-
* 2. For each entry, get the start and end index of that particular entry within the overall
|
|
57
|
-
* transcript. This allows us to reconstruct the transcript later from the original transcript
|
|
58
|
-
* and the search results.
|
|
59
|
-
*
|
|
60
|
-
* @private
|
|
61
|
-
* @memberof TranscriptIndex
|
|
62
|
-
*/
|
|
63
|
-
buildIndex(transcriptConfig) {
|
|
64
|
-
let startIndex = 0;
|
|
65
|
-
const transcriptEntryRanges = [];
|
|
66
|
-
let mergedTranscript = '';
|
|
67
|
-
transcriptConfig.entries.forEach((entry) => {
|
|
68
|
-
const { displayText } = entry;
|
|
69
|
-
const indexMapRange = new Range(startIndex, startIndex + displayText.length);
|
|
70
|
-
const indexMap = new TranscriptEntryRange(entry, indexMapRange);
|
|
71
|
-
transcriptEntryRanges.push(indexMap);
|
|
72
|
-
mergedTranscript += `${entry.rawText} `;
|
|
73
|
-
startIndex = mergedTranscript.length;
|
|
74
|
-
});
|
|
75
|
-
mergedTranscript = mergedTranscript.trim();
|
|
76
|
-
this.mergedTranscriptCache = mergedTranscript;
|
|
77
|
-
this.mergedTranscriptLowercasedCache = mergedTranscript.toLowerCase();
|
|
78
|
-
this.transcriptEntryRangesCache = transcriptEntryRanges;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
import { Range, TranscriptEntryRange } from './search-models';
|
|
2
|
+
/**
|
|
3
|
+
* The TranscriptIndex takes the original transcript and indexes it to make
|
|
4
|
+
* transcript entry lookups more efficient.
|
|
5
|
+
*/
|
|
6
|
+
export class TranscriptIndex {
|
|
7
|
+
constructor(transcriptConfig) {
|
|
8
|
+
/**
|
|
9
|
+
* This gets populated as part of the search index build. It merges all of the transcript
|
|
10
|
+
* entries together so we can search it as a single document instead of a bunch of
|
|
11
|
+
* individual entries. This allows searches to cross over transcript entries.
|
|
12
|
+
*
|
|
13
|
+
* NOTE: When the mergedTranscript gets created, spaces are put between each transcript
|
|
14
|
+
* entry, otherwise the words would run into each other. We account for this in the
|
|
15
|
+
* indices above.
|
|
16
|
+
*
|
|
17
|
+
* @type {string}
|
|
18
|
+
* @memberof TranscriptIndex
|
|
19
|
+
*/
|
|
20
|
+
this.mergedTranscriptCache = '';
|
|
21
|
+
this.mergedTranscriptLowercasedCache = '';
|
|
22
|
+
/**
|
|
23
|
+
* This gets populated as part of the search index build. It maps the start and end indicies
|
|
24
|
+
* of all of the transcript entries so we can quickly look up where an entry is in the
|
|
25
|
+
* overall transcript.
|
|
26
|
+
*
|
|
27
|
+
* @type {TranscriptEntryRange[]}
|
|
28
|
+
* @memberof TranscriptIndex
|
|
29
|
+
*/
|
|
30
|
+
this.transcriptEntryRangesCache = [];
|
|
31
|
+
this.buildIndex(transcriptConfig);
|
|
32
|
+
}
|
|
33
|
+
/** @inheritdoc */
|
|
34
|
+
get mergedTranscript() {
|
|
35
|
+
return this.mergedTranscriptCache;
|
|
36
|
+
}
|
|
37
|
+
/** @inheritdoc */
|
|
38
|
+
get mergedTranscriptLowercased() {
|
|
39
|
+
return this.mergedTranscriptLowercasedCache;
|
|
40
|
+
}
|
|
41
|
+
/** @inheritdoc */
|
|
42
|
+
get transcriptEntryRanges() {
|
|
43
|
+
return this.transcriptEntryRangesCache;
|
|
44
|
+
}
|
|
45
|
+
/** @inheritdoc */
|
|
46
|
+
getTranscriptEntryAt(overallCharIndex) {
|
|
47
|
+
return this.transcriptEntryRanges.find((entry) => {
|
|
48
|
+
const { range } = entry;
|
|
49
|
+
return range.endIndex > overallCharIndex && range.startIndex <= overallCharIndex;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build the search index. This method does two things:
|
|
54
|
+
* 1. Builds the "merged transcript" with all of the text combined into one long transcript.
|
|
55
|
+
* This allows us to search the entire thing at once instead of entry by entry.
|
|
56
|
+
* 2. For each entry, get the start and end index of that particular entry within the overall
|
|
57
|
+
* transcript. This allows us to reconstruct the transcript later from the original transcript
|
|
58
|
+
* and the search results.
|
|
59
|
+
*
|
|
60
|
+
* @private
|
|
61
|
+
* @memberof TranscriptIndex
|
|
62
|
+
*/
|
|
63
|
+
buildIndex(transcriptConfig) {
|
|
64
|
+
let startIndex = 0;
|
|
65
|
+
const transcriptEntryRanges = [];
|
|
66
|
+
let mergedTranscript = '';
|
|
67
|
+
transcriptConfig.entries.forEach((entry) => {
|
|
68
|
+
const { displayText } = entry;
|
|
69
|
+
const indexMapRange = new Range(startIndex, startIndex + displayText.length);
|
|
70
|
+
const indexMap = new TranscriptEntryRange(entry, indexMapRange);
|
|
71
|
+
transcriptEntryRanges.push(indexMap);
|
|
72
|
+
mergedTranscript += `${entry.rawText} `;
|
|
73
|
+
startIndex = mergedTranscript.length;
|
|
74
|
+
});
|
|
75
|
+
mergedTranscript = mergedTranscript.trim();
|
|
76
|
+
this.mergedTranscriptCache = mergedTranscript;
|
|
77
|
+
this.mergedTranscriptLowercasedCache = mergedTranscript.toLowerCase();
|
|
78
|
+
this.transcriptEntryRangesCache = transcriptEntryRanges;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
81
|
//# sourceMappingURL=transcript-index.js.map
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { LitElement, CSSResult, TemplateResult, PropertyValues } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* A widget to switch between search results that looks like this:
|
|
4
|
-
* < 3 / 7 >
|
|
5
|
-
*
|
|
6
|
-
* @export
|
|
7
|
-
* @class SearchResultsSwitcher
|
|
8
|
-
* @extends {LitElement}
|
|
9
|
-
*/
|
|
10
|
-
export default class SearchResultsSwitcher extends LitElement {
|
|
11
|
-
numberOfResults: number;
|
|
12
|
-
currentResultIndex: number;
|
|
13
|
-
/**
|
|
14
|
-
* LitElement life cycle render method. Entrypoint for rendering the element.
|
|
15
|
-
*
|
|
16
|
-
* @returns {TemplateResult}
|
|
17
|
-
* @memberof SearchResultsSwitcher
|
|
18
|
-
*/
|
|
19
|
-
render(): TemplateResult;
|
|
20
|
-
/**
|
|
21
|
-
* LitElement life cycle CSS for this element
|
|
22
|
-
*
|
|
23
|
-
* @readonly
|
|
24
|
-
* @static
|
|
25
|
-
* @type {CSSResult}
|
|
26
|
-
* @memberof SearchResultsSwitcher
|
|
27
|
-
*/
|
|
28
|
-
static get styles(): CSSResult;
|
|
29
|
-
/**
|
|
30
|
-
* LitElement lifecycle updated method
|
|
31
|
-
*
|
|
32
|
-
* @param {PropertyValues} changedProperties
|
|
33
|
-
* @memberof SearchResultsSwitcher
|
|
34
|
-
*/
|
|
35
|
-
updated(changedProperties: PropertyValues): void;
|
|
36
|
-
/**
|
|
37
|
-
* Called when user clicks on the previous result button.
|
|
38
|
-
* Loops around to the last result when we reach the first.
|
|
39
|
-
*
|
|
40
|
-
* @memberof SearchResultsSwitcher
|
|
41
|
-
*/
|
|
42
|
-
goToPreviousResult(): void;
|
|
43
|
-
/**
|
|
44
|
-
* Called when user clicks on the next result button.
|
|
45
|
-
* Loops around to the first result when we reach the last.
|
|
46
|
-
*
|
|
47
|
-
* @memberof SearchResultsSwitcher
|
|
48
|
-
*/
|
|
49
|
-
goToNextResult(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Emit an searchResultIndexChanged event that the index has been changed
|
|
52
|
-
*
|
|
53
|
-
* ie: `e.detail.searchResultIndex = 2`
|
|
54
|
-
*
|
|
55
|
-
* @memberof SearchResultsSwitcher
|
|
56
|
-
*/
|
|
57
|
-
emitSearchResultIndexChangedEvent(): void;
|
|
58
|
-
}
|
|
1
|
+
import { LitElement, CSSResult, TemplateResult, PropertyValues } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* A widget to switch between search results that looks like this:
|
|
4
|
+
* < 3 / 7 >
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class SearchResultsSwitcher
|
|
8
|
+
* @extends {LitElement}
|
|
9
|
+
*/
|
|
10
|
+
export default class SearchResultsSwitcher extends LitElement {
|
|
11
|
+
numberOfResults: number;
|
|
12
|
+
currentResultIndex: number;
|
|
13
|
+
/**
|
|
14
|
+
* LitElement life cycle render method. Entrypoint for rendering the element.
|
|
15
|
+
*
|
|
16
|
+
* @returns {TemplateResult}
|
|
17
|
+
* @memberof SearchResultsSwitcher
|
|
18
|
+
*/
|
|
19
|
+
render(): TemplateResult;
|
|
20
|
+
/**
|
|
21
|
+
* LitElement life cycle CSS for this element
|
|
22
|
+
*
|
|
23
|
+
* @readonly
|
|
24
|
+
* @static
|
|
25
|
+
* @type {CSSResult}
|
|
26
|
+
* @memberof SearchResultsSwitcher
|
|
27
|
+
*/
|
|
28
|
+
static get styles(): CSSResult;
|
|
29
|
+
/**
|
|
30
|
+
* LitElement lifecycle updated method
|
|
31
|
+
*
|
|
32
|
+
* @param {PropertyValues} changedProperties
|
|
33
|
+
* @memberof SearchResultsSwitcher
|
|
34
|
+
*/
|
|
35
|
+
updated(changedProperties: PropertyValues): void;
|
|
36
|
+
/**
|
|
37
|
+
* Called when user clicks on the previous result button.
|
|
38
|
+
* Loops around to the last result when we reach the first.
|
|
39
|
+
*
|
|
40
|
+
* @memberof SearchResultsSwitcher
|
|
41
|
+
*/
|
|
42
|
+
goToPreviousResult(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Called when user clicks on the next result button.
|
|
45
|
+
* Loops around to the first result when we reach the last.
|
|
46
|
+
*
|
|
47
|
+
* @memberof SearchResultsSwitcher
|
|
48
|
+
*/
|
|
49
|
+
goToNextResult(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Emit an searchResultIndexChanged event that the index has been changed
|
|
52
|
+
*
|
|
53
|
+
* ie: `e.detail.searchResultIndex = 2`
|
|
54
|
+
*
|
|
55
|
+
* @memberof SearchResultsSwitcher
|
|
56
|
+
*/
|
|
57
|
+
emitSearchResultIndexChangedEvent(): void;
|
|
58
|
+
}
|