// convenience methods --------------------------------------------------- /// <summary> /// A static convenience method that returns the first line of the /// specified file as list of strings, using the specified regexp as /// delimiter. /// </summary> /// <param name="filename">the file to read from</param> /// <param name="delim">a regexp on which to split lines into fields (default whitespace)</param> /// <exception cref="Java.IO.FileNotFoundException"/> public static IList <string> FirstRecord(string filename, string delim) { Edu.Stanford.Nlp.IO.RecordIterator it = new Edu.Stanford.Nlp.IO.RecordIterator(filename, delim); if (!it.MoveNext()) { return(null); } return(it.Current); }
// this line will be our next result // ----------------------------------------------------------------------- /// <summary>Just for testing.</summary> /// <remarks> /// Just for testing. Reads from the file named on the command line, or from /// stdin, and echoes the records it reads to stdout. /// </remarks> /// <exception cref="Java.IO.FileNotFoundException"/> public static void Main(string[] args) { Edu.Stanford.Nlp.IO.RecordIterator it = null; if (args.Length > 0) { it = new Edu.Stanford.Nlp.IO.RecordIterator(args[0]); } else { it = new Edu.Stanford.Nlp.IO.RecordIterator(Runtime.@in); log.Info("[Reading from stdin...]"); } while (it != null && it.MoveNext()) { IList <string> record = it.Current; foreach (string field in record) { System.Console.Out.Printf("[%-10s]", field); } System.Console.Out.WriteLine(); } }