/// <summary> /// Gets a list of lists expressing clusters within the Knowledge Base. /// </summary> /// <param name="number">Number of Clusters.</param> /// <param name="type">QName of a Type to cluster around.</param> /// <param name="callback">Callback to be invoked when the operation completes.</param> /// <param name="state">State to be passed to the callback.</param> /// <remarks> /// If the operation succeeds the callback will be invoked normally, if there is an error the callback will be invoked with a instance of <see cref="AsyncError"/> passed as the state which provides access to the error message and the original state passed in. /// </remarks> public void Cluster(int number, String type, PelletClusterServiceCallback callback, Object state) { ClusterRaw(number, type, (g, s) => { if (s is AsyncError) { callback(null, s); } else { // Build the List of Lists List <List <INode> > clusters = new List <List <INode> >(); foreach (INode clusterNode in g.Triples.SubjectNodes.Distinct()) { List <INode> cluster = new List <INode>(); foreach (Triple t in g.GetTriplesWithSubject(clusterNode)) { cluster.Add(t.Object); } cluster = cluster.Distinct().ToList(); clusters.Add(cluster); } callback(clusters, s); } }, state); }
/// <summary> /// Gets a list of lists expressing clusters within the Knowledge Base /// </summary> /// <param name="number">Number of Clusters</param> /// <param name="callback">Callback to be invoked when the operation completes</param> /// <param name="state">State to be passed to the callback</param> public void Cluster(int number, PelletClusterServiceCallback callback, Object state) { this.ClusterRaw(number, (g, s) => { //Build the List of Lists List <List <INode> > clusters = new List <List <INode> >(); foreach (INode clusterNode in g.Triples.SubjectNodes.Distinct()) { List <INode> cluster = new List <INode>(); foreach (Triple t in g.GetTriplesWithSubject(clusterNode)) { cluster.Add(t.Object); } cluster = cluster.Distinct().ToList(); clusters.Add(cluster); } callback(clusters, s); }, state); }
/// <summary> /// Gets a list of lists expressing clusters within the Knowledge Base /// </summary> /// <param name="number">Number of Clusters</param> /// <param name="type">QName of a Type to cluster around</param> /// <param name="callback">Callback to be invoked when the operation completes</param> /// <param name="state">State to be passed to the callback</param> public void Cluster(int number, String type, PelletClusterServiceCallback callback, Object state) { this.ClusterRaw(number, type, (g, s) => { //Build the List of Lists List<List<INode>> clusters = new List<List<INode>>(); foreach (INode clusterNode in g.Triples.SubjectNodes.Distinct()) { List<INode> cluster = new List<INode>(); foreach (Triple t in g.GetTriplesWithSubject(clusterNode)) { cluster.Add(t.Object); } cluster = cluster.Distinct().ToList(); clusters.Add(cluster); } callback(clusters, s); }, state); }