public static void Main(string[] args) { try { Opts opts = new Opts(); opts.ProcessArgs(args); if (opts.RemainingArguments.Length == 0 && opts.@out == "n3:-") { opts.DoHelp(); return; } if (!(opts.@out == "xml:-" || opts.@out == "n3:-")) { opts.stats = true; } StatementSink storage = Store.CreateForOutput(opts.@out); if (storage is RdfWriter && opts.outbaseuri != null) { ((RdfWriter)storage).BaseUri = opts.outbaseuri; } Entity meta = null; if (opts.meta != null) { meta = new Entity(opts.meta); } if (opts.clear) { if (!(storage is ModifiableSource)) { Console.Error.WriteLine("The --clear option cannot be used with this type of output method. Ignoring --clear."); } else { try { if (meta == null) { ((ModifiableSource)storage).Clear(); } else { ((ModifiableSource)storage).Remove(new Statement(null, null, null, meta)); } } catch (Exception e) { Console.Error.WriteLine("The --clear option was not successful: " + e.Message); } } } DateTime start_time = DateTime.Now; MultiRdfParser multiparser = new MultiRdfParser(opts.RemainingArguments, opts.@in, meta, opts.baseuri, !opts.stats); if (opts.buffer > 0) { CircularStatementBuffer buffer = new CircularStatementBuffer(opts.buffer); buffer.BeginReading(multiparser); buffer.BeginWriting(storage); buffer.Wait(); } else if (storage is ModifiableSource) { ((ModifiableSource)storage).Import(multiparser); } else { //if (!opts.makelean) { multiparser.Select(storage); /*} else { * MemoryStore st = new MemoryStore(multiparser); * StatementSink removed = null; * if (opts.leanprogress) * removed = new N3Writer(Console.Out); * if (opts.leanagainst != null) { * StatementSource against = Store.CreateForInput(opts.leanagainst); * if (!(against is SelectableSource)) * against = new MemoryStore(against); * Lean.MakeLean(st, (SelectableSource)against, removed); * } else if (storage is SelectableSource) { * Lean.MakeLean(st, (SelectableSource)storage, removed); * } else { * Lean.MakeLean(st, null, removed); * } * st.Select(storage); * }*/ } if (storage is IDisposable) { ((IDisposable)storage).Dispose(); } TimeSpan alltime = DateTime.Now - start_time; if (opts.stats) { Console.Error.WriteLine("Total Time: {0}m{1}s, {2} statements, {3} st/sec", (int)alltime.TotalMinutes, (int)alltime.Seconds, totalStatementsRead, alltime.TotalSeconds == 0 ? "?" : ((int)(totalStatementsRead / alltime.TotalSeconds)).ToString()); } } catch (Exception exc) { Console.Error.WriteLine(exc); } }
public static void Main(string[] args) { try { Opts opts = new Opts(); opts.ProcessArgs(args); if (opts.RemainingArguments.Length == 0 && opts.@out == "n3:-") { opts.DoHelp(); return; } if (!(opts.@out == "xml:-" || opts.@out == "n3:-")) opts.stats = true; StatementSink storage = Store.CreateForOutput(opts.@out); if (storage is RdfWriter && opts.outbaseuri != null) ((RdfWriter)storage).BaseUri = opts.outbaseuri; Entity meta = null; if (opts.meta != null) meta = new Entity(opts.meta); if (opts.clear) { if (!(storage is ModifiableSource)) { Console.Error.WriteLine("The --clear option cannot be used with this type of output method. Ignoring --clear."); } else { try { if (meta == null) ((ModifiableSource)storage).Clear(); else ((ModifiableSource)storage).Remove(new Statement(null, null, null, meta)); } catch (Exception e) { Console.Error.WriteLine("The --clear option was not successful: " + e.Message); } } } DateTime start_time = DateTime.Now; MultiRdfParser multiparser = new MultiRdfParser(opts.RemainingArguments, opts.@in, meta, opts.baseuri, !opts.stats); if (opts.buffer > 0) { CircularStatementBuffer buffer = new CircularStatementBuffer(opts.buffer); buffer.BeginReading(multiparser); buffer.BeginWriting(storage); buffer.Wait(); } else if (storage is ModifiableSource) { ((ModifiableSource)storage).Import(multiparser); } else { //if (!opts.makelean) { multiparser.Select(storage); /*} else { MemoryStore st = new MemoryStore(multiparser); StatementSink removed = null; if (opts.leanprogress) removed = new N3Writer(Console.Out); if (opts.leanagainst != null) { StatementSource against = Store.CreateForInput(opts.leanagainst); if (!(against is SelectableSource)) against = new MemoryStore(against); Lean.MakeLean(st, (SelectableSource)against, removed); } else if (storage is SelectableSource) { Lean.MakeLean(st, (SelectableSource)storage, removed); } else { Lean.MakeLean(st, null, removed); } st.Select(storage); }*/ } if (storage is IDisposable) ((IDisposable)storage).Dispose(); TimeSpan alltime = DateTime.Now - start_time; if (opts.stats) Console.Error.WriteLine("Total Time: {0}m{1}s, {2} statements, {3} st/sec", (int)alltime.TotalMinutes, (int)alltime.Seconds, totalStatementsRead, alltime.TotalSeconds == 0 ? "?" : ((int)(totalStatementsRead/alltime.TotalSeconds)).ToString()); } catch (Exception exc) { Console.Error.WriteLine(exc); } }