Normalizes the arguments passed to `foregroundChild`.

See the signature of `foregroundChild` for the supported arguments.

@param fgArgs Array of arguments passed to `foregroundChild`.
@return Normalized arguments
@internal
332258
function normalizeFgArgs(fgArgs) {
  var program, args, cb;
  var processArgsEnd = fgArgs.length;
  var lastFgArg = fgArgs[fgArgs.length - 1];
  if (typeof lastFgArg === "function") {
    cb = lastFgArg;
    processArgsEnd -= 1;
  } else {
    cb = function(done) { done(); };
  }

  if (Array.isArray(fgArgs[0])) {
    program = fgArgs[0][0];
    args = fgArgs[0].slice(1);
  } else {
    program = fgArgs[0];
    args = Array.isArray(fgArgs[1]) ? fgArgs[1] : fgArgs.slice(1, processArgsEnd);
  }

  return {program: program, args: args, cb: cb};
}
975342
function normalizeFns(fns) {
  Object.keys(fns).forEach(function(key) {
    var handler = fns[key];
    if (typeof handler === 'function') {
      fns[key] = {
        enter: handler,
        leave: noop
      };
    }
  });
}
353731
function normalizeArgs(args, exclude) {
    var result = [];
    args = splitArgs(args || []);
    exclude = splitArgs(exclude || []);
    args.slice(0).forEach(function (arg) {
        var val;
        if (arg && arg.indexOf && ~arg.indexOf('=')) {
            var kv = arg.split('=');
            arg = kv[0];
            val = kv[1];
        }
        if (/^-{1}[a-z]+/i.test(arg)) {
            var spread = arg.slice(1).split('').map(function (a) { return '-' + a; });
            if (val)
                spread.push(val);
            result = result.concat(spread);
        }
        else {
            result.push(arg);
            if (val)
                result.push(val);
        }
    });
    return filterArgs(result, exclude);
}
484677
function getNormalizationType (
  children,
  maybeComponent
) {
  var res = 0;
  for (var i = 0; i < children.length; i++) {
    var el = children[i];
    if (el.type !== 1) {
      continue
    }
    // TODO: a better normalization mode without text node combination
    // it was 2 full normalizatiom before
    // but it will combine two adjacent text node which will cause hid and context infomation lost
    if (needsNormalization(el) ||
        (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
      // res = 2
      res = 1;
      break
    }
    if (maybeComponent(el) ||
        (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
      res = 1;
    }
  }
  return res
}
885524
public T addServerArguments(final String... args) {
        if (args != null) {
            for (String arg : args) {
                addServerArgument(arg);
            }
        }
        return getThis();
    }
572738
@Override
  public Tree normalizeWholeTree(Tree tree, TreeFactory tf) {
    TreeTransformer transformer1 = new TreeTransformer() {
      public Tree transformTree(Tree t) {
        if (doSGappedStuff) {
          String lab = t.label().value();
          if (lab.equals("S") && includesEmptyNPSubj(t)) {
            LabelFactory lf = t.label().labelFactory();
            // Note: this changes the tree label, rather than
            // creating a new tree node.  Beware!
            t.setLabel(lf.newLabel(t.label().value() + "-G"));
          }
        }
        return t;
      }
    };
    Filter<Tree> subtreeFilter = new Filter<Tree>() {
      /**
       *
       */
      private static final long serialVersionUID = -7250433816896327901L;

      public boolean accept(Tree t) {
        Tree[] kids = t.children();
        Label l = t.label();
        // The special Switchboard non-terminals clause.
        // Note that it deletes IP which other Treebanks might use!
        if ("RS".equals(t.label().value()) || "RM".equals(t.label().value()) || "IP".equals(t.label().value()) || "CODE".equals(t.label().value())) {
          return false;
        }
        if ((l != null) && l.value() != null && (l.value().equals("-NONE-")) && !t.isLeaf() && kids.length == 1 && kids[0].isLeaf()) {
          // Delete empty/trace nodes (ones marked '-NONE-')
          return false;
        }
        return true;
      }
    };
    Filter<Tree> nodeFilter = new Filter<Tree>() {
      /**
       *
       */
      private static final long serialVersionUID = 9000955019205336311L;

      public boolean accept(Tree t) {
        if (t.isLeaf() || t.isPreTerminal()) {
          return true;
        }
        // The special switchboard non-terminals clause. Try keeping EDITED for now....
        // if ("EDITED".equals(t.label().value())) {
        //   return false;
        // }
        if (t.numChildren() != 1) {
          return true;
        }
        if (t.label() != null && t.label().value() != null && t.label().value().equals(t.children()[0].label().value())) {
          return false;
        }
        return true;
      }
    };
    TreeTransformer transformer2 = new TreeTransformer() {
      public Tree transformTree(Tree t) {
        if (temporalAnnotation == TEMPORAL_ANY_TMP_PERCOLATED) {
          String lab = t.label().value();
          if (TmpPattern.matcher(lab).matches()) {
            Tree oldT = t;
            Tree ht;
            do {
              ht = headFinder.determineHead(oldT);
              // special fix for possessives! -- make noun before head
              if (ht.label().value().equals("POS")) {
                int j = oldT.indexOf(ht);
                if (j > 0) {
                  ht = oldT.getChild(j - 1);
                }
              }
              LabelFactory lf = ht.label().labelFactory();
              // Note: this changes the tree label, rather than
              // creating a new tree node.  Beware!
              ht.setLabel(lf.newLabel(ht.label().value() + "-TMP"));
              oldT = ht;
            } while (!ht.isPreTerminal());
            if (lab.startsWith("PP")) {
              ht = headFinder.determineHead(t);
              // look to right
              int j = t.indexOf(ht);
              int sz = t.children().length;
              if (j + 1 < sz) {
                ht = t.getChild(j + 1);
              }
              if (ht.label().value().startsWith("NP")) {
                while (!ht.isLeaf()) {
                  LabelFactory lf = ht.label().labelFactory();
                  // Note: this changes the tree label, rather than
                  // creating a new tree node.  Beware!
                  ht.setLabel(lf.newLabel(ht.label().value() + "-TMP"));
                  ht = headFinder.determineHead(ht);
                }
              }
            }
          }
        } else if (temporalAnnotation == TEMPORAL_ALL_TERMINALS) {
          String lab = t.label().value();
          if (NPTmpPattern.matcher(lab).matches()) {
            Tree ht;
            ht = headFinder.determineHead(t);
            if (ht.isPreTerminal()) {
              // change all tags to -TMP
              LabelFactory lf = ht.label().labelFactory();
              Tree[] kids = t.children();
              for (Tree kid : kids) {
                if (kid.isPreTerminal()) {
                  // Note: this changes the tree label, rather
                  // than creating a new tree node.  Beware!
                  kid.setLabel(lf.newLabel(kid.value() + "-TMP"));
                }
              }
            } else {
              Tree oldT = t;
              do {
                ht = headFinder.determineHead(oldT);
                oldT = ht;
              } while (!ht.isPreTerminal());
              LabelFactory lf = ht.label().labelFactory();
              // Note: this changes the tree label, rather than
              // creating a new tree node.  Beware!
              ht.setLabel(lf.newLabel(ht.label().value() + "-TMP"));
            }
          }
        } else if (temporalAnnotation == TEMPORAL_ALL_NP) {
          String lab = t.label().value();
          if (NPTmpPattern.matcher(lab).matches()) {
            Tree oldT = t;
            Tree ht;
            do {
              ht = headFinder.determineHead(oldT);
              // special fix for possessives! -- make noun before head
              if (ht.label().value().equals("POS")) {
                int j = oldT.indexOf(ht);
                if (j > 0) {
                  ht = oldT.getChild(j - 1);
                }
              }
              if (ht.isPreTerminal() || ht.value().startsWith("NP")) {
                LabelFactory lf = ht.labelFactory();
                // Note: this changes the tree label, rather than
                // creating a new tree node.  Beware!
                ht.setLabel(lf.newLabel(ht.label().value() + "-TMP"));
                oldT = ht;
              }
            } while (ht.value().startsWith("NP"));
          }
        } else if (temporalAnnotation == TEMPORAL_ALL_NP_AND_PP || temporalAnnotation == TEMPORAL_NP_AND_PP_WITH_NP_HEAD || temporalAnnotation == TEMPORAL_ALL_NP_EVEN_UNDER_PP) {
          // also allow chain to start with PP
          String lab = t.value();
          if (NPTmpPattern.matcher(lab).matches() || PPTmpPattern.matcher(lab).matches()) {
            Tree oldT = t;
            do {
              Tree ht = headFinder.determineHead(oldT);
              // special fix for possessives! -- make noun before head
              if (ht.value().equals("POS")) {
                int j = oldT.indexOf(ht);
                if (j > 0) {
                  ht = oldT.getChild(j - 1);
                }
              } else if ((temporalAnnotation == TEMPORAL_NP_AND_PP_WITH_NP_HEAD || temporalAnnotation == TEMPORAL_ALL_NP_EVEN_UNDER_PP) && (ht.value().equals("IN") || ht.value().equals("TO"))) {
                // change the head to be NP if possible
                Tree[] kidlets = oldT.children();
                for (int k = kidlets.length - 1; k > 0; k--) {
                  if (kidlets[k].value().startsWith("NP")) {
                    ht = kidlets[k];
                  }
                }
              }
              LabelFactory lf = ht.labelFactory();
              // Note: this next bit changes the tree label, rather
              // than creating a new tree node.  Beware!
              if (ht.isPreTerminal() || ht.value().startsWith("NP")) {
                ht.setLabel(lf.newLabel(ht.value() + "-TMP"));
              }
              if (temporalAnnotation == TEMPORAL_ALL_NP_EVEN_UNDER_PP && oldT.value().startsWith("PP")) {
                oldT.setLabel(lf.newLabel(tlp.basicCategory(oldT.value())));
              }
              oldT = ht;
            } while (oldT.value().startsWith("NP") || oldT.value().startsWith("PP"));
          }
        } else if (temporalAnnotation == TEMPORAL_ALL_NP_PP_ADVP) {
          // also allow chain to start with PP or ADVP
          String lab = t.value();
          if (NPTmpPattern.matcher(lab).matches() || PPTmpPattern.matcher(lab).matches() || ADVPTmpPattern.matcher(lab).matches()) {
            Tree oldT = t;
            do {
              Tree ht = headFinder.determineHead(oldT);
              // special fix for possessives! -- make noun before head
              if (ht.value().equals("POS")) {
                int j = oldT.indexOf(ht);
                if (j > 0) {
                  ht = oldT.getChild(j - 1);
                }
              }
              // Note: this next bit changes the tree label, rather
              // than creating a new tree node.  Beware!
              if (ht.isPreTerminal() || ht.value().startsWith("NP")) {
                LabelFactory lf = ht.labelFactory();
                ht.setLabel(lf.newLabel(ht.value() + "-TMP"));
              }
              oldT = ht;
            } while (oldT.value().startsWith("NP"));
          }
        } else if (temporalAnnotation == TEMPORAL_9) {
          // also allow chain to start with PP or ADVP
          String lab = t.value();
          if (NPTmpPattern.matcher(lab).matches() || PPTmpPattern.matcher(lab).matches() || ADVPTmpPattern.matcher(lab).matches()) {
            // System.err.println("TMP: Annotating " + t);
            addTMP9(t);
          }
        } else if (temporalAnnotation == TEMPORAL_ACL03PCFG) {
          String lab = t.label().value();
          if (lab != null && NPTmpPattern.matcher(lab).matches()) {
            Tree oldT = t;
            Tree ht;
            do {
              ht = headFinder.determineHead(oldT);
              // special fix for possessives! -- make noun before head
              if (ht.label().value().equals("POS")) {
                int j = oldT.indexOf(ht);
                if (j > 0) {
                  ht = oldT.getChild(j - 1);
                }
              }
              oldT = ht;
            } while (!ht.isPreTerminal());
            if ( ! onlyTagAnnotateNstar || ht.label().value().startsWith("N")) {
              LabelFactory lf = ht.label().labelFactory();
              // Note: this changes the tree label, rather than
              // creating a new tree node.  Beware!
              ht.setLabel(lf.newLabel(ht.label().value() + "-TMP"));
            }
          }
        }
        if (doAdverbialNP) {
          String lab = t.value();
          if (NPAdvPattern.matcher(lab).matches()) {
            Tree oldT = t;
            Tree ht;
            do {
              ht = headFinder.determineHead(oldT);
              // special fix for possessives! -- make noun before head
              if (ht.label().value().equals("POS")) {
                int j = oldT.indexOf(ht);
                if (j > 0) {
                  ht = oldT.getChild(j - 1);
                }
              }
              if (ht.isPreTerminal() || ht.value().startsWith("NP")) {
                LabelFactory lf = ht.labelFactory();
                // Note: this changes the tree label, rather than
                // creating a new tree node.  Beware!
                ht.setLabel(lf.newLabel(ht.label().value() + "-ADV"));
                oldT = ht;
              }
            } while (ht.value().startsWith("NP"));
          }
        }
        return t;
      }
    };
    // if there wasn't an empty nonterminal at the top, but an S, wrap it.
    if (tree.label().value().equals("S")) {
      tree = tf.newTreeNode("ROOT", Collections.singletonList(tree));
    }
    // repair for the phrasal VB in Switchboard (PTB version 3) that should be a VP
    for (Tree subtree : tree) {
      if (subtree.isPhrasal() && "VB".equals(subtree.label().value())) {
        subtree.setValue("VP");
      }
    }
    tree = tree.transform(transformer1);
    if (tree == null) { return null; }
    tree = tree.prune(subtreeFilter, tf);
    if (tree == null) { return null; }
    tree = tree.spliceOut(nodeFilter, tf);
    if (tree == null) { return null; }
    return tree.transform(transformer2, tf);
  }
893466
protected function normalizeArgs(array $args)
    {
        $error = $this->app->make('helper/validation/error');
        $normalized = [];
        $normalized['territoryRequestLevel'] = null;
        if (isset($args['territoryRequestLevel']) && (is_int($args['territoryRequestLevel']) || (is_string($args['territoryRequestLevel']) && is_numeric($args['territoryRequestLevel'])))) {
            $i = (int) $args['territoryRequestLevel'];
            switch ($i) {
                case self::TERRITORYREQUESTLEVEL_NEVER:
                case self::TERRITORYREQUESTLEVEL_OPTIONAL:
                case self::TERRITORYREQUESTLEVEL_NOTSOOPTIONAL:
                case self::TERRITORYREQUESTLEVEL_ALWAYS:
                    $normalized['territoryRequestLevel'] = $i;
                    break;
            }
        }
        if ($normalized['territoryRequestLevel'] === null) {
            $error->add(t('Please specify if and how the territory should be required'));
        }

        return $error->has() ? $error : $normalized;
    }
461797
function compositeRGB(foreground, background) {
  const [fr, fg, fb, fa] = chroma(foreground).rgba()
  const [br, bg, bb] = chroma(background).rgb()
  return chroma([(1 - fa) * br + fa * fr, (1 - fa) * bg + fa * fg, (1 - fa) * bb + fa * fb]).css()
}
542260
function normalizeOptions(options = {}) {
    const hasGroups = options.groups && options.groups.length > 0;
    const groups = hasGroups ? options.groups : DEFAULT_GROUPS;
    const allowSamePrecedence = options.allowSamePrecedence !== false;

    return {
        groups,
        allowSamePrecedence
    };
}
520837
public String[] processOptions(String args[])
    {
        targetPackage = "";        // default to no package
        compilerEnv.setGenerateDebugInfo(false);   // default to no symbols
        for (int i=0; i < args.length; i++) {
            String arg = args[i];
            if (!arg.startsWith("-")) {
                int tail = args.length - i;
                if (targetName != null && tail > 1) {
                    addError("msg.multiple.js.to.file", targetName);
                    return null;
                }
                String[] result = new String[tail];
                for (int j = 0; j != tail; ++j) {
                    result[j] = args[i + j];
                }
                return result;
            }
            if (arg.equals("-help") || arg.equals("-h")
                || arg.equals("--help"))
            {
                printHelp = true;
                return null;
            }

            try {
                if (arg.equals("-version") && ++i < args.length) {
                    int version = Integer.parseInt(args[i]);
                    compilerEnv.setLanguageVersion(version);
                    continue;
                }
                if ((arg.equals("-opt") || arg.equals("-O"))  &&
                    ++i < args.length)
                {
                    int optLevel = Integer.parseInt(args[i]);
                    compilerEnv.setOptimizationLevel(optLevel);
                    continue;
                }
            }
            catch (NumberFormatException e) {
                badUsage(args[i]);
                return null;
            }
            if (arg.equals("-nosource")) {
                compilerEnv.setGeneratingSource(false);
                continue;
            }
            if (arg.equals("-debug") || arg.equals("-g")) {
                compilerEnv.setGenerateDebugInfo(true);
                continue;
            }
            if (arg.equals("-main-method-class") && ++i < args.length) {
                compiler.setMainMethodClass(args[i]);
                continue;
            }
            if (arg.equals("-encoding") && ++i < args.length) {
                characterEncoding = args[i];
                continue;
            }
            if (arg.equals("-o") && ++i < args.length) {
                String name = args[i];
                int end = name.length();
                if (end == 0
                    || !Character.isJavaIdentifierStart(name.charAt(0)))
                {
                    addError("msg.invalid.classfile.name", name);
                    continue;
                }
                for (int j = 1; j < end; j++) {
                    char c = name.charAt(j);
                    if (!Character.isJavaIdentifierPart(c)) {
                        if (c == '.') {
                            // check if it is the dot in .class
                            if (j == end - 6 && name.endsWith(".class")) {
                                name = name.substring(0, j);
                                break;
                            }
                        }
                        addError("msg.invalid.classfile.name", name);
                        break;
                    }
                }
                targetName = name;
                continue;
            }
            if (arg.equals("-observe-instruction-count")) {
                compilerEnv.setGenerateObserverCount(true);
            }
            if (arg.equals("-package") && ++i < args.length) {
                String pkg = args[i];
                int end = pkg.length();
                for (int j = 0; j != end; ++j) {
                    char c = pkg.charAt(j);
                    if (Character.isJavaIdentifierStart(c)) {
                        for (++j; j != end; ++j) {
                            c = pkg.charAt(j);
                            if (!Character.isJavaIdentifierPart(c)) {
                                break;
                            }
                        }
                        if (j == end) {
                            break;
                        }
                        if (c == '.' && j != end - 1) {
                            continue;
                        }
                    }
                    addError("msg.package.name", targetPackage);
                    return null;
                }
                targetPackage = pkg;
                continue;
            }
            if (arg.equals("-extends") && ++i < args.length) {
                String targetExtends = args[i];
                Class<?> superClass;
                try {
                    superClass = Class.forName(targetExtends);
                } catch (ClassNotFoundException e) {
                    throw new Error(e.toString()); // TODO: better error
                }
                compiler.setTargetExtends(superClass);
                continue;
            }
            if (arg.equals("-implements") && ++i < args.length) {
                // TODO: allow for multiple comma-separated interfaces.
                String targetImplements = args[i];
                StringTokenizer st = new StringTokenizer(targetImplements,
                                                         ",");
                List<Class<?>> list = new ArrayList<Class<?>>();
                while (st.hasMoreTokens()) {
                    String className = st.nextToken();
                    try {
                        list.add(Class.forName(className));
                    } catch (ClassNotFoundException e) {
                        throw new Error(e.toString()); // TODO: better error
                    }
                }
                Class<?>[] implementsClasses = list.toArray(new Class<?>[list.size()]);
                compiler.setTargetImplements(implementsClasses);
                continue;
            }
            if (arg.equals("-d") && ++i < args.length) {
                destinationDir = args[i];
                continue;
            }
            badUsage(arg);
            return null;
        }
        // no file name
        p(ToolErrorReporter.getMessage("msg.no.file"));
        return null;
    }
663140
function joinMsgArgs(msgArgs) {
         if (!msgArgs) {
             return '';
         }
         return msgArgs.map((arg) => {
            if (arg === null) {
                return 'null';
            } else if (typeof arg === 'undefined') {
                return 'undefined';
            } else if (typeof arg === 'string') {
                 return arg;
             } else if (typeof arg === 'object') {
                 try {
                     return JSON.stringify(arg);
                 } catch (ex) {
                     return arg.toString();
                 }
             } else { // boolean, symbol, number, function
                 return arg.toString();
             }
         }).join(' ');
     }
13130
public Front normalize(Front front) {
    if (front == null) {
      throw new JMetalException("The front is null") ;
    }

    return getNormalizedFront(front, maximumValues, minimumValues);
  }
1222226
private static List<String> convertSpecialStringTags(List<String> extraArgs) {
        if (extraArgs == null) {
            return null;
        }
        List<String> args = new ArrayList<String>();
        for (String arg : extraArgs) {
            args.add(StringToObjectConverter.convertSpecialStringTags(arg));
        }
        return args;
    }
212275
protected function normalizeMailArgs(array $args): array
    {
        // If the first argument is an array, use it as the mail configuration
        if (is_array($args[0])) {
            return $args[0];
        }
        $result = [];
        $length = count($args);
        // FIXME This is a weak way to handle the arguments, since a change in the order will break it
        for ($i = 0; $i < $length; $i++) {
            $result[$this->argumentsMapping[$i]] = $args[$i];
        }
        return $result;
    }
768266
private static long computeMsgId(MsgNode msgNode) {
    return SoyMsgIdComputer.computeMsgId(
        buildMsgParts(msgNode), msgNode.getMeaning(), msgNode.getContentType());
  }
1183327
public List<Term> seg(char[] text)
    {
        assert text != null;
        if (HanLP.Config.Normalization)
        {
            CharTable.normalization(text);
        }
        return segSentence(text);
    }
447723
function _normalizeVertexTree(vertex) {
  var children = vertex.get('children');

  if(children) {
    children = children.filter(function (child) {
      _normalizeVertexTree(child);
      return child.get('type') !== 'vertex' || child.get('treeParent') === vertex;
    });

    vertex._setChildren(children);
  }

  return vertex;
}