@@ -422,7 +422,7 @@ export class SpeechExplorer
422422 ] ) ;
423423
424424 /**
425- * Semantic id to subtee map.
425+ * Semantic id to subtree map.
426426 */
427427 private subtrees : Map < string , Set < string > > = new Map ( ) ;
428428
@@ -1765,6 +1765,9 @@ export class SpeechExplorer
17651765 return focus . join ( ' ' ) ;
17661766 }
17671767
1768+ /**
1769+ * Populates the subtrees map from the data-semantic-structure attribute.
1770+ */
17681771 private getSubtrees ( ) {
17691772 const node = this . node . querySelector ( '[data-semantic-structure]' ) ;
17701773 if ( ! node ) return ;
@@ -1775,23 +1778,23 @@ export class SpeechExplorer
17751778 }
17761779}
17771780
1778- // Some Aux functions
1781+ // Some Aux functions for parsing the semantic structure sexpression
17791782//
17801783type SexpTree = string | SexpTree [ ] ;
17811784
1782- // Helper to tokenize input
17831785/**
1786+ * Helper to tokenize input
17841787 *
1785- * @param str
1788+ * @param str The semantic structure.
17861789 */
17871790function tokenize ( str : string ) : string [ ] {
17881791 return str . replace ( / \( / g, ' ( ' ) . replace ( / \) / g, ' ) ' ) . trim ( ) . split ( / \s + / ) ;
17891792}
17901793
1791- // Recursive parser to convert tokens into a tree
17921794/**
1795+ * Recursive parser to convert tokens into a tree
17931796 *
1794- * @param tokens
1797+ * @param tokens The tokens from the semantic structure.
17951798 */
17961799function parse ( tokens : string [ ] ) : SexpTree {
17971800 if ( ! tokens . length ) return null ;
@@ -1810,11 +1813,11 @@ function parse(tokens: string[]): SexpTree {
18101813 }
18111814}
18121815
1813- // Flatten tree and build the map
18141816/**
1817+ * Flattens the tree and builds the map.
18151818 *
1816- * @param tree
1817- * @param map
1819+ * @param tree The sexpression tree.
1820+ * @param map The map to populate.
18181821 */
18191822function buildMap ( tree : SexpTree , map = new Map ( ) ) {
18201823 if ( typeof tree === 'string' ) {
@@ -1839,11 +1842,12 @@ function buildMap(tree: SexpTree, map = new Map()) {
18391842 return descendants ;
18401843}
18411844
1842- // Can be replaced with ES2024
1845+ // Can be replaced with ES2024 implementation of Set.prototyp.difference
18431846/**
1847+ * Set difference between two sets A and B: A\B.
18441848 *
1845- * @param a
1846- * @param b
1849+ * @param a Initial set.
1850+ * @param b Set to remove from A.
18471851 */
18481852function setdifference ( a : Set < string > , b : Set < string > ) : Set < string > {
18491853 if ( ! a ) {
0 commit comments