/// <summary> /// Convert a dependency graph to a format expected as input to /// <see cref="IWriter.Set(string, object)"/> /// . /// </summary> private static object BuildDependencyTree(SemanticGraph graph) { // It's lying; we need the "redundant" casts (as of 2014-09-08) if (graph != null) { return(IStream.Concat(graph.GetRoots().Stream().Map(null), graph.EdgeListSorted().Stream().Map(null))); } else { // Roots // Regular edges return(null); } }
/// <exception cref="System.IO.IOException"/> public static void Main(string[] args) { RedwoodConfiguration.Standard().Apply(); Redwood.Util.StartTrack("main"); // Read the data IStream <SimpleSentiment.SentimentDatum> data = IStream.Concat(IStream.Concat(IStream.Concat(Imdb("/users/gabor/tmp/aclImdb/train/pos", SentimentClass.Positive), Imdb("/users/gabor/tmp/aclImdb/train/neg", SentimentClass.Negative)), IStream.Concat (Imdb("/users/gabor/tmp/aclImdb/test/pos", SentimentClass.Positive), Imdb("/users/gabor/tmp/aclImdb/test/neg", SentimentClass.Negative))), IStream.Concat(IStream.Concat(Stanford("/users/gabor/tmp/train.tsv"), Stanford("/users/gabor/tmp/test.tsv" )), IStream.Concat(Twitter("/users/gabor/tmp/twitter.csv"), Unlabelled("/users/gabor/tmp/wikipedia")))); // Train the model OutputStream stream = IOUtils.GetFileOutputStream("/users/gabor/tmp/model.ser.gz"); SimpleSentiment classifier = SimpleSentiment.Train(data, Optional.Of(stream)); stream.Close(); log.Info(classifier.Classify("I think life is great")); Redwood.Util.EndTrack("main"); }