All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.util.logging.RerouteChannel Maven / Gradle / Ivy

Go to download

Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.

There is a newer version: 4.5.7
Show newest version

package edu.stanford.nlp.util.logging;

import java.util.ArrayList;
import java.util.List;

import edu.stanford.nlp.util.logging.Redwood.Record;

public class RerouteChannel extends LogRecordHandler {
  
  private Object oldChannelName;
  private Object newChannelName;

  public RerouteChannel(Object oldChannelName, Object newChannelName) {
    this.oldChannelName = oldChannelName;
    this.newChannelName = newChannelName;
  }

  public List handle(Record record) {
    List results = new ArrayList<>();
    
    Object[] channels = record.channels();
    for (int i = 0; i < channels.length; i++) {
      Object channel = channels[i];
      if (oldChannelName.equals(channel)) {
        // make a new version of the Record with a different channel name
        channels[i] = newChannelName;
        Record reroutedRecord = new Record(record.content, channels, record.depth, record.timesstamp);
        results.add(reroutedRecord);
        return results;
      }
    }
    
    // didn't find any matching records, so just return the original one
    results.add(record);
    return results;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy