  function segment_word(referenceText, dictionary) {
                const leftToRight = leftToRightSegmentation(referenceText, dictionary);
                const rightToLeft = rightToLeftSegmentation(referenceText, dictionary);
                if (leftToRight.join("") === referenceText) {
                    return leftToRight;
                } else if (rightToLeft.join("") === referenceText) {
                    return rightToLeft;
                } else {
                    console.log("WW failed to s