middlewares/formatter.js
/**
 * Convert an array of array of tokens to full FN-style PT.GF
 * Detect UD (Universal Dependencies) and PENN constituent tags and convert
 * to full valid FrameNet PhraseType and GrammaticalFunctions.
 */
Convert an array of array of tokens to full FN-style PT.GF
Detect UD (Universal Dependencies) and PENN constituent tags and convert
to full valid FrameNet PhraseType and GrammaticalFunctions.
Convert an array of array of tokens to full FN - style PT . GF Detect UD ( Universal Dependencies ) and PENN constituent tags and convert to full valid FrameNet PhraseType and GrammaticalFunctions .
function convertPTandGFtoFNstyle(context, next) {
  const fVPq = context.valencer.query.vp.formatted.map(vu => vu.reduce((array, item) => {
    if (Object.prototype.hasOwnProperty.call(constants.UD_TO_FN_MAPPING, item)) {
      context.valencer.query.vp.hasUDtags = true;
      array.push(constants.UD_TO_FN_MAPPING[item].PT);
      array.push(constants.UD_TO_FN_MAPPING[item].GF);
    } else if (Object.prototype.hasOwnProperty.call(constants.PENN_CONST_TO_FN_MAPPING, item)) {
      context.valencer.query.vp.hasPENNtags = true;
      array.push(constants.PENN_CONST_TO_FN_MAPPING[item]);
    } else {
      array.push(item);
    }
    return array;
  }, []));
  context.valencer.query.vp.formatted = fVPq;
  logger.debug(`Formatted query after mapping = ${JSON.stringify(context.valencer.query.vp.formatted)}`);
  return next();
}
function convertPTandGFtoFNstyle ( context , next ) { const fVPq = context . valencer . query . vp . formatted . map ( vu => vu . reduce ( ( array , item ) => { if ( Object . prototype . hasOwnProperty . call ( constants . UD_TO_FN_MAPPING , item ) ) { context . valencer . query . vp . hasUDtags = true ; array . push ( constants . UD_TO_FN_MAPPING [ item ] . PT ) ; array . push ( constants . UD_TO_FN_MAPPING [ item ] . GF ) ; } else if ( Object . prototype . hasOwnProperty . call ( constants . PENN_CONST_TO_FN_MAPPING , item ) ) { context . valencer . query . vp . hasPENNtags = true ; array . push ( constants . PENN_CONST_TO_FN_MAPPING [ item ] ) ; } else { array . push ( item ) ; } return array ; } , [ ] ) ) ; context . valencer . query . vp . formatted = fVPq ; logger . debug ( ` ${ JSON . stringify ( context . valencer . query . vp . formatted ) } ` ) ; return next ( ) ; }
Convert an array of array of tokens to full FN-style PT.GF
 Detect UD (Universal Dependencies) and PENN constituent tags and convert
 to full valid FrameNet PhraseType and GrammaticalFunctions.
Convert an array of array of tokens to full FN - style PT . GF Detect UD ( Universal Dependencies ) and PENN constituent tags and convert to full valid FrameNet PhraseType and GrammaticalFunctions .