import * as R from 'ramda' ; import domify from '../../utils/domify/domify' ; const isBadgeNode = ( node ) => node instanceof Element && node . classList . contains ( 'synopp' ) ; const extractSynonymOrAntonym = ( whatToExtract ) => ( senseMarkup ) => { const synonymOrAntonymWrapper = domify ( senseMarkup ) . querySelector ( whatToExtract === 'synonym' ? '.SYN' : '.OPP' ) ; if ( ! synonymOrAntonymWrapper ) { return '' ; } const synonymOrAntonym = Array . from ( synonymOrAntonymWrapper . childNodes ) . filter ( node => ! isBadgeNode ( node ) ) . map ( R . prop ( 'textContent' ) ) . join ( ' ' ) . trim ( ) ; return synonymOrAntonym ; } ; export const extractSynonym = extractSynonymOrAntonym ( 'synonym' ) ; export const extractAntonym = extractSynonymOrAntonym ( 'antonym' ) ;