Clear[OB];
OB[w_LW] /; Deg[w]==1 := w[[1]];
OB[w_LW] := OB[w] = Overscript[
Row[Riffle[OB /@ LyndonFactorization[w], " "]],
⎴
];
OB[⟨"xxxxxxxxxxxxxyxxxxxxy"⟩]

OB /@ AllLyndonWords[8, {"x", "y"}]

Clear[OB];
OB[w_LW] /; Deg[w]==1 := w[[1]];
OB[w_LW] := OB[w] = Overscript[
Row[Riffle[OB /@ LyndonFactorization[w], " "], BaselinePosition->Center],
⎴
];
OB[⟨"xxxxxxxxxxxxxyxxxxxxy"⟩]

OB /@ AllLyndonWords[8, {"x", "y"}]