Exemple #1
0
        /// <summary>
        /// An example of clustering data from an arbitrary byte stream holding input XML for
        /// the DCS (can be an in-memory stream if clustering from a string).
        /// </summary>
        private static void ClusterFromStream(MultipartFileUpload service, Stream xmlStream, string queryHint)
        {
            // The output format is XML.
            service.AddFormValue("dcs.output.format", "XML");

            // We don't need documents in the output, only clusters.
            service.AddFormValue("dcs.clusters.only", "true");

            // Pass query hint.
            service.AddFormValue("query", queryHint);

            // The algorithm to use for clustering. Omit to select the default. An example of
            // using Lingo with custom parameters follows.

            service.AddFormValue("dcs.algorithm", "lingo");
            service.AddFormValue("LingoClusteringAlgorithm.desiredClusterCountBase", "10");
            service.AddFormValue("LingoClusteringAlgorithm.factorizationQuality", "LOW");
            service.AddFormValue("LingoClusteringAlgorithm.factorizationFactory",
                "org.carrot2.matrix.factorization.PartialSingularValueDecompositionFactory");

            // Add the XML stream here.
            service.AddFormStream("dcs.c2stream", "anything.xml", xmlStream);

            // Perform the actual query.
            byte[] response = service.Post();

            // Parse the output and dump group headers.
            MemoryStream input = new MemoryStream(response);

            XmlDocument document = new XmlDocument();
            document.PreserveWhitespace = true;
            document.Load(input);

            PrintResults(document);
        }
Exemple #2
0
        /// <summary>
        /// Cluster data retrieved from a search engine or some other source registered in the
        /// DCS as a document source.
        /// </summary>
        private static void ClusterFromSearchEngine(MultipartFileUpload service, string sourceId, string query)
        {
            // The output format is XML.
            service.AddFormValue("dcs.output.format", "XML");

            // This time we will be interested in both clusters and documents.
            service.AddFormValue("dcs.clusters.only", "false");

            // Add query.
            service.AddFormValue("query", query);

            // Add the number of results.
            service.AddFormValue("results", "20");

            // Specify the source.
            service.AddFormValue("dcs.source", sourceId);

            // Perform the actual query.
            byte[] response = service.Post();

            // Parse the output and dump group headers.
            MemoryStream input = new MemoryStream(response);

            XmlDocument document = new XmlDocument();

            document.PreserveWhitespace = true;
            document.Load(input);

            PrintResults(document);
        }
Exemple #3
0
        /// <summary>
        /// An example of clustering data from an arbitrary byte stream holding input XML for
        /// the DCS (can be an in-memory stream if clustering from a string).
        /// </summary>
        private static void ClusterFromStream(MultipartFileUpload service, Stream xmlStream, string queryHint)
        {
            // The output format is XML.
            service.AddFormValue("dcs.output.format", "XML");

            // We don't need documents in the output, only clusters.
            service.AddFormValue("dcs.clusters.only", "true");

            // Pass query hint.
            service.AddFormValue("query", queryHint);

            // The algorithm to use for clustering. Omit to select the default. An example of
            // using Lingo with custom parameters follows.

            service.AddFormValue("dcs.algorithm", "lingo");
            service.AddFormValue("LingoClusteringAlgorithm.desiredClusterCountBase", "10");
            service.AddFormValue("LingoClusteringAlgorithm.factorizationQuality", "LOW");
            service.AddFormValue("LingoClusteringAlgorithm.factorizationFactory",
                                 "org.carrot2.matrix.factorization.PartialSingularValueDecompositionFactory");

            // Add the XML stream here.
            service.AddFormStream("dcs.c2stream", "anything.xml", xmlStream);

            // Perform the actual query.
            byte[] response = service.Post();

            // Parse the output and dump group headers.
            MemoryStream input = new MemoryStream(response);

            XmlDocument document = new XmlDocument();

            document.PreserveWhitespace = true;
            document.Load(input);

            PrintResults(document);
        }
Exemple #4
0
        /// <summary>
        /// Cluster data retrieved from a search engine or some other source registered in the
        /// DCS as a document source.
        /// </summary>
        private static void ClusterFromSearchEngine(MultipartFileUpload service, string sourceId, string query)
        {
            // The output format is XML.
            service.AddFormValue("dcs.output.format", "XML");

            // This time we will be interested in both clusters and documents.
            service.AddFormValue("dcs.clusters.only", "false");

            // Add query.
            service.AddFormValue("query", query);

            // Add the number of results.
            service.AddFormValue("results", "20");

            // Specify the source.
            service.AddFormValue("dcs.source", sourceId);

            // Perform the actual query.
            byte[] response = service.Post();

            // Parse the output and dump group headers.
            MemoryStream input = new MemoryStream(response);

            XmlDocument document = new XmlDocument();
            document.PreserveWhitespace = true;
            document.Load(input);

            PrintResults(document);
        }