Esempio n. 1
0
        /// <summary>This will do the escaping on an input file.</summary>
        /// <remarks>
        /// This will do the escaping on an input file. Input file should already be tokenized,
        /// with tokens separated by whitespace. <br />
        /// Usage: java edu.stanford.nlp.process.PTBEscapingProcessor fileOrUrl
        /// </remarks>
        /// <param name="args">Command line argument: a file or URL</param>
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                System.Console.Out.WriteLine("usage: java edu.stanford.nlp.process.PTBEscapingProcessor fileOrUrl");
                return;
            }
            string filename = args[0];

            try
            {
                IDocument <string, Word, Word> d;
                // initialized below
                if (filename.StartsWith("http://"))
                {
                    IDocument <string, Word, Word> dpre = new BasicDocument <string>(WhitespaceTokenizer.Factory()).Init(new URL(filename));
                    IDocumentProcessor <Word, Word, string, Word> notags = new StripTagsProcessor <string, Word>();
                    d = notags.ProcessDocument(dpre);
                }
                else
                {
                    d = new BasicDocument <string>(WhitespaceTokenizer.Factory()).Init(new File(filename));
                }
                IDocumentProcessor <Word, IHasWord, string, Word> proc = new Edu.Stanford.Nlp.Process.PTBEscapingProcessor <Word, string, Word>();
                IDocument <string, Word, IHasWord> newD = proc.ProcessDocument(d);
                foreach (IHasWord word in newD)
                {
                    System.Console.Out.WriteLine(word);
                }
            }
            catch (Exception e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
        }
Esempio n. 2
0
        /// <summary>This will print out some text, recognizing tags.</summary>
        /// <remarks>
        /// This will print out some text, recognizing tags.  It can be used to
        /// test tag breaking.  <br />  Usage: <code>
        /// java edu.stanford.nlp.process.WordToTaggedWordProcessor fileOrUrl
        /// </code>
        /// </remarks>
        /// <param name="args">Command line argument: a file or URL</param>
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                System.Console.Out.WriteLine("usage: java edu.stanford.nlp.process.WordToTaggedWordProcessor fileOrUrl");
                System.Environment.Exit(0);
            }
            string filename = args[0];

            try
            {
                IDocument <IHasWord, Word, Word> d;
                if (filename.StartsWith("http://"))
                {
                    IDocument <IHasWord, Word, Word> dpre = new BasicDocument <IHasWord>().Init(new URL(filename));
                    IDocumentProcessor <Word, Word, IHasWord, Word> notags = new StripTagsProcessor <IHasWord, Word>();
                    d = notags.ProcessDocument(dpre);
                }
                else
                {
                    d = new BasicDocument <IHasWord>().Init(new File(filename));
                }
                IDocumentProcessor <Word, IHasWord, IHasWord, Word> proc = new Edu.Stanford.Nlp.Process.WordToTaggedWordProcessor <Word, IHasWord, Word>();
                IDocument <IHasWord, Word, IHasWord> sentd = proc.ProcessDocument(d);
                // System.out.println(sentd);
                int i = 0;
                foreach (IHasWord w in sentd)
                {
                    System.Console.Out.WriteLine(i + ": " + w);
                    i++;
                }
            }
            catch (Exception e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
        }