Beispiel #1
0
        private void GetTickers()
        {
            if (Date == null || Text == null)
            {
                Console.WriteLine("Skipping ticker extraction since either date or text were not found");
                return;
            }
            Console.WriteLine("Extracting tickers");
            var calais   = new CalaisDotNet("", Text);
            var document = calais.Call <CalaisJsonDocument>();

            try
            {
                JObject json = JObject.Parse(document.RawOutput);
                Tickers = json.
                          Properties().
                          Where(key => (string)key.Value.SelectToken("_type") == "Company").
                          Select(key => (string)key.Value.SelectToken("resolutions[0].ticker")).
                          Where(ticker => ticker != null).
                          ToArray();
                Console.WriteLine("Found tickers: {0}", String.Join(", ", Tickers));
            }
            catch (Exception e)
            {
                Console.WriteLine("WARNING: could not extract tickers from this document. {0}", e.Message);
            }
        }
Beispiel #2
0
        public void ParseUrl(string content)
        {
            // A couple options: http://stackoverflow.com/questions/123336/how-can-you-strip-non-ascii-characters-from-a-string-in-c
            string asAscii = Encoding.ASCII.GetString(
                Encoding.Convert(
                    Encoding.UTF8,
                    Encoding.GetEncoding(
                        Encoding.ASCII.EncodingName,
                        new EncoderReplacementFallback(string.Empty),
                        new DecoderExceptionFallback()
                        ),
                    Encoding.UTF8.GetBytes(content)
                    )
                );

            CalaisDotNet calais = new CalaisDotNet(apikey, asAscii);

            document = calais.Call <CalaisSimpleDocument>();
            // CalaisRdfDocument rdf = calais.Call<CalaisRdfDocument>();
        }
Beispiel #3
0
        private void GetTickers()
        {
            if (Date == null || Text == null)
            {
                Console.WriteLine("Skipping ticker extraction since either date or text were not found");
                return;
            }
            Console.WriteLine("Extracting tickers");
            var calais = new CalaisDotNet("", Text);
            var document = calais.Call<CalaisJsonDocument>();

            try
            {
                JObject json = JObject.Parse(document.RawOutput);
                Tickers = json.
                    Properties().
                    Where(key => (string)key.Value.SelectToken("_type") == "Company").
                    Select(key => (string)key.Value.SelectToken("resolutions[0].ticker")).
                    Where(ticker => ticker != null).
                    ToArray();
                Console.WriteLine("Found tickers: {0}", String.Join(", ", Tickers));
            }
            catch (Exception e)
            {
                Console.WriteLine("WARNING: could not extract tickers from this document. {0}", e.Message);
            }
        }