public void map(LongWritable key, Text value, Context context)
     throws IOException, InterruptedException {
   String cur_file =
       ((FileSplit) context.getInputSplit()).getPath().getParent().getParent().getName();
   String train_file = context.getConfiguration().get("train_file");
   if (cur_file.equals(train_file)) {
     StringTokenizer st = new StringTokenizer(value.toString());
     String word = st.nextToken();
     String f_id = st.nextToken();
     myKey.set(word);
     myVal.set(f_id);
     context.write(myKey, myVal);
   } else {
     StringTokenizer st = new StringTokenizer(value.toString());
     String word = st.nextToken();
     String f_id = st.nextToken();
     StringBuilder builder = new StringBuilder(dlt);
     while (st.hasMoreTokens()) {
       String filename = st.nextToken();
       String tf_idf = st.nextToken();
       builder.append(filename);
       builder.append(dlt);
       builder.append(tf_idf);
       builder.append("\t");
     }
     myKey.set(word);
     myVal.set(builder.toString());
     context.write(myKey, myVal);
   }
 }
Exemple #2
1
  /**
   * This is a convenience method to lookup a remote object by name within the naming context.
   *
   * @exception javax.naming.NamingException if the object with that name could not be found.
   */
  public static java.rmi.Remote lookupObject(String publishedName, java.lang.Class anInterface)
      throws javax.naming.NamingException {

    Context ic = new InitialContext();
    java.lang.Object objRef = ic.lookup(publishedName);
    return (java.rmi.Remote) PortableRemoteObject.narrow(objRef, anInterface);
  }
Exemple #3
1
  private static void defineProperties(Context cx, JaggeryContext context, ScriptableObject scope) {

    JavaScriptProperty request = new JavaScriptProperty("request");
    HttpServletRequest servletRequest = (HttpServletRequest) context.getProperty(SERVLET_REQUEST);
    request.setValue(cx.newObject(scope, "Request", new Object[] {servletRequest}));
    request.setAttribute(ScriptableObject.READONLY);
    RhinoEngine.defineProperty(scope, request);

    JavaScriptProperty response = new JavaScriptProperty("response");
    HttpServletResponse servletResponse =
        (HttpServletResponse) context.getProperty(SERVLET_RESPONSE);
    response.setValue(cx.newObject(scope, "Response", new Object[] {servletResponse}));
    response.setAttribute(ScriptableObject.READONLY);
    RhinoEngine.defineProperty(scope, response);

    JavaScriptProperty session = new JavaScriptProperty("session");
    session.setValue(cx.newObject(scope, "Session", new Object[] {servletRequest.getSession()}));
    session.setAttribute(ScriptableObject.READONLY);
    RhinoEngine.defineProperty(scope, session);

    JavaScriptProperty application = new JavaScriptProperty("application");
    ServletContext servletConext = (ServletContext) context.getProperty(Constants.SERVLET_CONTEXT);
    application.setValue(cx.newObject(scope, "Application", new Object[] {servletConext}));
    application.setAttribute(ScriptableObject.READONLY);
    RhinoEngine.defineProperty(scope, application);

    if (isWebSocket(servletRequest)) {
      JavaScriptProperty websocket = new JavaScriptProperty("webSocket");
      websocket.setValue(cx.newObject(scope, "WebSocket", new Object[0]));
      websocket.setAttribute(ScriptableObject.READONLY);
      RhinoEngine.defineProperty(scope, websocket);
    }
  }
Exemple #4
1
  @Override
  public void map(LongWritable key, Text value, Context context)
      throws IOException, InterruptedException {
    String line = value.toString();

    // skip the header
    if (line.startsWith(OTPConsts.HEADER_START)) return;

    // two possible input format: 1. prediction input, 2. query input
    String k;
    String v;
    String[] splits = line.split(",");
    if (line.startsWith("P")) {
      // handle prediction input
      k = extractKey(splits, 1, 5);
      v =
          splits[6]
              + OTPConsts.COMMA
              + splits[7]
              + OTPConsts.COMMA
              + splits[8]
              + OTPConsts.COMMA
              + splits[9];
      context.write(new Text(k), new Text(v));
    } else {
      k = extractKey(splits, 0, -1);
      v = "Q";
      context.write(new Text(k), new Text(v));
    }
  }
Exemple #5
1
    public void reduce(Text key, Iterable<Text> values, Context context)
        throws IOException, InterruptedException {

      String keyS = key.toString();
      if (keyS.startsWith("O") || keyS.startsWith("P") || keyS.startsWith("S")) {
        String sum = new String();

        for (Text val : values) {

          sum += (" " + val.toString());
        }

        // String subKey = keyS.substring(0,keyS.length()-1);

        // Text t = new Text();
        // t.set(subKey);
        result.set(sum);
        context.write(key, result);
      }
      if (keyS.startsWith("L")) {
        //	String [] keyIdS = keyS.substring(1).split("[+]");

        result.set(" ");
        context.write(key, result);

        // String KeyIdS1 = keyIdS[1];
        // result.set(KeyIdS1);
        // context.write(key, result);

        // String KeyIdS2 = keyIdS[2];
        // result.set(KeyIdS2);
        // context.write(key, result);

      }
    }
 public static boolean testCommand(
     final Context context,
     final String command,
     final String contains,
     final List<String> arguments) {
   try {
     final List<String> commandAndArgs = new ArrayList<String>();
     commandAndArgs.add(command);
     commandAndArgs.addAll(arguments);
     final ProcessBuilder pb = new ProcessBuilder(commandAndArgs);
     logCommand(context, pb);
     final Process compilation = pb.start();
     final ConsumeStream result = ConsumeStream.start(compilation.getInputStream(), null);
     final ConsumeStream error = ConsumeStream.start(compilation.getErrorStream(), null);
     compilation.waitFor();
     result.join();
     error.join();
     return error.output.toString().contains(contains)
         || result.output.toString().contains(contains);
   } catch (IOException ex) {
     context.log(ex.getMessage());
     return false;
   } catch (InterruptedException ex) {
     context.log(ex.getMessage());
     return false;
   }
 }
 @Override
 public void put(String name, Scriptable start, Object value) {
   int info = findInstanceIdInfo(name);
   if (info != 0) {
     if (start == this && isSealed()) {
       throw Context.reportRuntimeError1("msg.modify.sealed", name);
     }
     int attr = (info >>> 16);
     if ((attr & READONLY) == 0) {
       if (start == this) {
         int id = (info & 0xFFFF);
         setInstanceIdValue(id, value);
       } else {
         start.put(name, start, value);
       }
     }
     return;
   }
   if (prototypeValues != null) {
     int id = prototypeValues.findId(name);
     if (id != 0) {
       if (start == this && isSealed()) {
         throw Context.reportRuntimeError1("msg.modify.sealed", name);
       }
       prototypeValues.set(id, start, value);
       return;
     }
   }
   super.put(name, start, value);
 }
Exemple #8
0
  public Expr classify(Context ctxt, int approx, boolean spec) {
    if (ctxt.getFlag("debug_classify_term_apps")) {
      ctxt.w.print("(Classifying ");
      print(ctxt.w, ctxt);
      ctxt.w.println("");
      ctxt.w.flush();
    }
    Expr cl = head.classify(ctxt, approx, spec).defExpandTop(ctxt, false, spec);
    Expr ret = apply_classifier(FUN_TYPE, approx, spec, ctxt, cl, 0);
    FunType ch = (FunType) ((FunType) cl).coalesce(ctxt, spec);
    boolean check_spec_terminates = ctxt.getFlag("check_spec_terminates");
    for (int i = 0; i < X.length; i++) {
      if (ch.owned[i].status == Ownership.SPEC) {
        if (check_spec_terminates) X[i].checkTermination(ctxt);
        specarg[i] = true;
      }
    }
    if (ctxt.getFlag("debug_classify_term_apps")) {
      ctxt.w.println(") Classifier is:");
      ret.print(ctxt.w, ctxt);
      ctxt.w.println("");
      ctxt.w.flush();
    }

    return ret;
  }
Exemple #9
0
  public Expr dropNoncompArgs(Context ctxt) {
    if (ctxt.getFlag("debug_drop_noncomp")) {
      ctxt.w.println("Dropping non-comp arguments from term-app " + toString(ctxt));
      ctxt.w.flush();
    }
    ArrayList nX = new ArrayList();
    ArrayList no = new ArrayList();
    boolean changed = false;
    Boolean b = new Boolean(false);
    for (int i = 0, iend = X.length; i < iend; i++) {
      if (X[i].isProof(ctxt) || specarg[i]) changed = true;
      else {
        nX.add(X[i]);
        no.add(b);
      }
    }

    Expr ret = this;
    if (changed) {
      if (nX.size() == 0) ret = head;
      else ret = new TermApp(head, Parser.toExprArray(nX), Parser.toBooleanArray(no));
    }

    if (ctxt.getFlag("debug_drop_noncomp")) {
      ctxt.w.println("Returning " + ret.toString(ctxt));
      ctxt.w.flush();
    }

    return ret;
  }
Exemple #10
0
  /**
   * Utility method which dynamically binds a Context to the current thread, if none already exists.
   */
  public static Object callMethod(
      ContextFactory factory,
      final Scriptable thisObj,
      final Function f,
      final Object[] args,
      final long argsToWrap) {
    if (f == null) {
      // See comments in getFunction
      return Undefined.instance;
    }
    if (factory == null) {
      factory = ContextFactory.getGlobal();
    }

    final Scriptable scope = f.getParentScope();
    if (argsToWrap == 0) {
      return Context.call(factory, f, scope, thisObj, args);
    }

    Context cx = Context.getCurrentContext();
    if (cx != null) {
      return doCall(cx, scope, thisObj, f, args, argsToWrap);
    } else {
      return factory.call(
          new ContextAction() {
            public Object run(Context cx) {
              return doCall(cx, scope, thisObj, f, args, argsToWrap);
            }
          });
    }
  }
Exemple #11
0
  /** Construct a log with given I/O redirections. */
  protected Log(
      Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) {
    super(JCDiagnostic.Factory.instance(context));
    context.put(logKey, this);
    this.errWriter = errWriter;
    this.warnWriter = warnWriter;
    this.noticeWriter = noticeWriter;

    @SuppressWarnings("unchecked") // FIXME
    DiagnosticListener<? super JavaFileObject> dl = context.get(DiagnosticListener.class);
    this.diagListener = dl;

    diagnosticHandler = new DefaultDiagnosticHandler();

    messages = JavacMessages.instance(context);
    messages.add(Main.javacBundleName);

    final Options options = Options.instance(context);
    initOptions(options);
    options.addListener(
        new Runnable() {
          public void run() {
            initOptions(options);
          }
        });
  }
 @Override
 public void init(Context context, Properties initProps) {
   dataField = context.getEntityAttribute("dataField");
   encoding = context.getEntityAttribute("encoding");
   entityProcessor = (EntityProcessorWrapper) context.getEntityProcessor();
   /*no op*/
 }
 public Object getDefaultValue(Class<?> hint) {
   Object value;
   if (hint == null) {
     if (javaObject instanceof Boolean) {
       hint = ScriptRuntime.BooleanClass;
     }
   }
   if (hint == null || hint == ScriptRuntime.StringClass) {
     value = javaObject.toString();
   } else {
     String converterName;
     if (hint == ScriptRuntime.BooleanClass) {
       converterName = "booleanValue";
     } else if (hint == ScriptRuntime.NumberClass) {
       converterName = "doubleValue";
     } else {
       throw Context.reportRuntimeError0("msg.default.value");
     }
     Object converterObject = get(converterName, this);
     if (converterObject instanceof Function) {
       Function f = (Function) converterObject;
       value = f.call(Context.getContext(), f.getParentScope(), this, ScriptRuntime.emptyArgs);
     } else {
       if (hint == ScriptRuntime.NumberClass && javaObject instanceof Boolean) {
         boolean b = ((Boolean) javaObject).booleanValue();
         value = ScriptRuntime.wrapNumber(b ? 1.0 : 0.0);
       } else {
         value = javaObject.toString();
       }
     }
   }
   return value;
 }
Exemple #14
0
  public static JaggeryContext clonedJaggeryContext(ServletContext context) {
    JaggeryContext shared = sharedJaggeryContext(context);
    RhinoEngine engine = shared.getEngine();
    Scriptable sharedScope = shared.getScope();
    Context cx = Context.getCurrentContext();
    ScriptableObject instanceScope = (ScriptableObject) cx.newObject(sharedScope);
    instanceScope.setPrototype(sharedScope);
    instanceScope.setParentScope(null);

    JaggeryContext clone = new JaggeryContext();
    clone.setEngine(engine);
    clone.setTenantId(shared.getTenantId());
    clone.setScope(instanceScope);

    clone.addProperty(Constants.SERVLET_CONTEXT, shared.getProperty(Constants.SERVLET_CONTEXT));
    clone.addProperty(LogHostObject.LOG_LEVEL, shared.getProperty(LogHostObject.LOG_LEVEL));
    clone.addProperty(
        FileHostObject.JAVASCRIPT_FILE_MANAGER,
        shared.getProperty(FileHostObject.JAVASCRIPT_FILE_MANAGER));
    clone.addProperty(
        Constants.JAGGERY_CORE_MANAGER, shared.getProperty(Constants.JAGGERY_CORE_MANAGER));
    clone.addProperty(Constants.JAGGERY_INCLUDED_SCRIPTS, new HashMap<String, Boolean>());
    clone.addProperty(Constants.JAGGERY_INCLUDES_CALLSTACK, new Stack<String>());
    clone.addProperty(Constants.JAGGERY_REQUIRED_MODULES, new HashMap<String, ScriptableObject>());

    CommonManager.setJaggeryContext(clone);

    return clone;
  }
  @Override
  public void reduce(IntWritable key, Iterable<WriteableData> values, Context context)
      throws IOException, InterruptedException {

    DaalContext daalContext = new DaalContext();

    /* Create an algorithm to compute a sparse variance-covariance matrix on the master node */
    DistributedStep2Master covarianceSparseMaster =
        new DistributedStep2Master(daalContext, Double.class, Method.fastCSR);

    for (WriteableData value : values) {
      PartialResult pr = (PartialResult) value.getObject(daalContext);
      covarianceSparseMaster.input.add(DistributedStep2MasterInputId.partialResults, pr);
    }

    /* Compute a sparse variance-covariance matrix on the master node */
    covarianceSparseMaster.compute();

    /* Finalize computations and retrieve the results */
    Result result = covarianceSparseMaster.finalizeCompute();

    HomogenNumericTable covariance = (HomogenNumericTable) result.get(ResultId.covariance);
    HomogenNumericTable mean = (HomogenNumericTable) result.get(ResultId.mean);

    context.write(new IntWritable(0), new WriteableData(covariance));
    context.write(new IntWritable(1), new WriteableData(mean));

    daalContext.dispose();
  }
Exemple #16
0
  public QLender(String queuecf, String requestQueue) {
    try {
      // Connect to the provider and get the JMS connection
      Context ctx = new InitialContext();
      QueueConnectionFactory qFactory = (QueueConnectionFactory) ctx.lookup(queuecf);
      qConnect = qFactory.createQueueConnection();

      // Create the JMS Session
      qSession = qConnect.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

      // Lookup the request queue
      requestQ = (Queue) ctx.lookup(requestQueue);

      // Now that setup is complete, start the Connection
      qConnect.start();

      // Create the message listener
      QueueReceiver qReceiver = qSession.createReceiver(requestQ);
      qReceiver.setMessageListener(this);

      System.out.println("Waiting for loan requests...");

    } catch (JMSException jmse) {
      jmse.printStackTrace();
      System.exit(1);
    } catch (NamingException jne) {
      jne.printStackTrace();
      System.exit(1);
    }
  }
Exemple #17
0
 /**
  * Creates a new SPEC properties object as above
  *
  * @param baseDir base directory / URL prefix
  * @param setupColor background color of the setup screen
  */
 public SpecProps(String baseDir, Color setupColor) {
   this(
       baseDir,
       "props/spec",
       ((Context.getUserPropFile() == null) ? baseDir + "props/user" : Context.getUserPropFile()),
       "props/title",
       setupColor);
 }
 Class<?> getPluginClass(String packageName, String className)
     throws NameNotFoundException, ClassNotFoundException {
   Context pluginContext =
       this.mAppContext.createPackageContext(
           packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
   ClassLoader pluginCL = pluginContext.getClassLoader();
   return pluginCL.loadClass(className);
 }
 private VerticleHolder getVerticleHolder() {
   Context context = vertx.getContext();
   if (context != null) {
     VerticleHolder holder = (VerticleHolder) context.getDeploymentHandle();
     return holder;
   } else {
     return null;
   }
 }
Exemple #20
0
  /** Load a object of type 'clazz' from a file. */
  public <T> T load(Class<T> clazz, InputStream is) throws JAXBException {
    Context context;
    T object;

    context = getContext(clazz);
    synchronized (context) {
      object = (T) context.unmarshal(is);
      return object;
    }
  }
 public static List<File> findFiles(
     final Context context, final File path, final List<String> extensions) {
   context.log("Searching for files...");
   for (final String ext : extensions) {
     context.log("Matching: " + ext);
   }
   final List<File> foundFiles = new LinkedList<File>();
   findFiles(context, path, foundFiles, extensions);
   return foundFiles;
 }
 // Must be synchronized since called directly from different thread
 private void addVerticle(Deployment deployment, Verticle verticle, VerticleFactory factory) {
   String loggerName =
       "org.vertx.deployments." + deployment.name + "-" + deployment.verticles.size();
   Logger logger = LoggerFactory.getLogger(loggerName);
   Context context = vertx.getContext();
   VerticleHolder holder =
       new VerticleHolder(
           deployment, context, verticle, loggerName, logger, deployment.config, factory);
   deployment.verticles.add(holder);
   context.setDeploymentHandle(holder);
 }
Exemple #23
0
  /** Save a object to a outputstream. */
  private void save(Object object, OutputStream os) throws JAXBException, IOException {
    Writer writer;
    Context context;

    writer = new OutputStreamWriter(os);

    context = getContext(object.getClass());
    synchronized (context) {
      context.marshal(object, writer);
    }
  }
    public void reduce(GFKey key, Iterable<PEIWritable> values, Context context)
        throws IOException, InterruptedException {
      // For a particular key ... process all records and output what we would have expected in this
      // concKnownKeys test
      // Note that we either
      // 1. do a single create
      // 2. create + update
      // 3. create + destroy
      // look at all ops ... and output either
      // 1. create
      // 2. create (with value from update)
      // 3. do nothing (overall result is destroy, so do not create the entry in the gemfire
      // validation region
      String keyStr = (String) key.getKey();
      ValueHolder updateValue = null;
      ValueHolder createValue = null;
      boolean destroyed = false;
      System.out.println("KnownKeysMRv2.reduce() invoked with " + keyStr);
      for (PEIWritable value : values) {
        PersistedEventImpl event = value.getEvent();
        Operation op = event.getOperation();

        ValueHolder vh = null;
        if (op.isDestroy()) {
          destroyed = true;
        } else {
          try {
            vh = (ValueHolder) event.getDeserializedValue();
          } catch (ClassNotFoundException e) {
            System.out.println(
                "KnownKeysMRv2.map() caught " + e + " : " + TestHelper.getStackTrace(e));
          }
          if (op.isUpdate()) {
            updateValue = vh;
          } else {
            createValue = vh;
          }
        }
        System.out.println(
            "KnownKeysMRv2.reduce() record: "
                + op.toString()
                + ": key = "
                + keyStr
                + " and op "
                + op.toString());
      }
      if (!destroyed) {
        if (updateValue != null) {
          context.write(key.getKey(), updateValue);
        } else {
          context.write(key.getKey(), createValue);
        }
      }
    }
Exemple #25
0
 /**
  * @param context
  * @return
  */
 public static String version(final Context context) {
   String version = null;
   try {
     final PackageInfo packageinfo =
         context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
     version = packageinfo.versionName;
   } catch (Exception x) {
     DBG.m(x);
   }
   return version;
 }
Exemple #26
0
    private static void WriteNewCentroids(Context context) throws IOException {
      FileSystem fs = FileSystem.get(context.getConfiguration());
      Path nextCFile = new Path(context.getConfiguration().get("NEXTCFILE"));
      DataOutputStream d = new DataOutputStream(fs.create(nextCFile, false));
      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(d));

      for (String centroid : newCentroids) {
        writer.write(centroid + "\n");
      }

      writer.close();
    }
  public void sendEMailToUser(ICFSecuritySecUserObj toUser, String msgSubject, String msgBody)
      throws IOException, MessagingException, NamingException {

    final String S_ProcName = "sendEMailToUser";

    Properties props = System.getProperties();

    Context ctx = new InitialContext();

    String smtpEmailFrom = (String) ctx.lookup("java:comp/env/CFInternet25SmtpEmailFrom");
    if ((smtpEmailFrom == null) || (smtpEmailFrom.length() <= 0)) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(
              getClass(), S_ProcName, 0, "JNDI lookup for CFInternet25SmtpEmailFrom");
    }

    smtpUsername = (String) ctx.lookup("java:comp/env/CFInternet25SmtpUsername");
    if ((smtpUsername == null) || (smtpUsername.length() <= 0)) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(
              getClass(), S_ProcName, 0, "JNDI lookup for CFInternet25SmtpUsername");
    }

    smtpPassword = (String) ctx.lookup("java:comp/env/CFInternet25SmtpPassword");
    if ((smtpPassword == null) || (smtpPassword.length() <= 0)) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(
              getClass(), S_ProcName, 0, "JNDI lookup for CFInternet25SmtpPassword");
    }

    Session emailSess =
        Session.getInstance(
            props,
            new Authenticator() {
              protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(smtpUsername, smtpPassword);
              }
            });

    MimeMessage msg = new MimeMessage(emailSess);
    msg.setFrom(new InternetAddress(smtpEmailFrom));
    InternetAddress mailTo[] = InternetAddress.parse(toUser.getRequiredEMailAddress(), false);
    msg.setRecipient(Message.RecipientType.TO, mailTo[0]);
    msg.setSubject((msgSubject != null) ? msgSubject : "No subject");
    msg.setSentDate(new Date());
    msg.setContent(msgBody, "text/html");
    msg.saveChanges();

    Transport.send(msg);
  }
Exemple #28
0
 /**
  * @param context
  * @return
  */
 public static String getApplicationName(final Context context) {
   String name = null;
   try {
     final PackageManager packagemanager = context.getPackageManager();
     final PackageInfo packageinfo = packagemanager.getPackageInfo(context.getPackageName(), 0);
     name =
         packageinfo.applicationInfo.loadLabel(packagemanager).toString()
             + "("
             + packageinfo.packageName
             + ")";
   } catch (Exception x) {
     DBG.m(x);
   }
   return name;
 }
Exemple #29
0
  public App spineForm(Context ctxt, boolean drop_annos, boolean spec, boolean expand_defs) {
    Expr h = head;
    Expr prev = null;
    if (expand_defs) {
      Expr prev2 = null;
      while (h != prev) {
        prev2 = prev;
        prev = h;
        h = h.defExpandOne(ctxt, drop_annos, spec);
      }
      if (prev2 != null) prev = prev2;

      if (h.construct != construct && h.construct != CONST && h.construct != VAR)
        /* we are trying to keep these constructs in the head. */
        h = prev;
    }

    if (ctxt.getFlag("debug_spine_form")) {
      ctxt.w.println("Computing spine form of " + toString(ctxt));
      ctxt.w.println("{");
      ctxt.w.println("Head expands to " + h.toString(ctxt));
      ctxt.w.flush();
    }
    App ret = this;
    if (h.construct == construct) {
      TermApp e = (TermApp) ((TermApp) h).spineForm(ctxt, drop_annos, spec, expand_defs);
      int eXlen = e.X.length;
      int newlen = X.length + eXlen;
      Expr[] X2 = new Expr[newlen];
      boolean[] specarg2 = new boolean[newlen];
      for (int i = 0; i < eXlen; i++) {
        X2[i] = e.X[i];
        specarg2[i] = e.specarg[i];
      }
      for (int i = 0, iend = X.length; i < iend; i++) {
        X2[i + eXlen] = X[i];
        specarg2[i + eXlen] = specarg[i];
      }
      ret = new TermApp(e.head, X2, specarg2);
    } else if (h != head) ret = new TermApp(h, X, specarg);

    if (ctxt.getFlag("debug_spine_form")) {
      ret.print(ctxt.w, ctxt);
      ctxt.w.println("\n}");
      ctxt.w.flush();
    }
    return ret;
  }
    @Override
    protected void setup(Context context) throws IOException, InterruptedException {
      if (context.getCacheFiles() != null && context.getCacheFiles().length > 0) {

        InputStream in = new FileInputStream(new File("./mergedLineCounts2"));
        BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
        String line;

        while ((line = reader.readLine()) != null) {
          String[] split = line.split("\t");
          wordCounts.put(split[0], Integer.parseInt(split[1]));
        }
      }

      super.setup(context);
    }