mergedServices.SPARQLQueryBuilder.buildQueries C# (CSharp) Méthode

buildQueries() public méthode

Builds and returns a set of queries to find relations between two object1 and object2.
public buildQueries ( string object1, string object2, int maxDistance, int limit, List ignoredObjects = null, List ignoredProperties = null, int avoidCycles ) : List
object1 string object1
object2 string object2
maxDistance int MaxiumDistance between the two objects
limit int Limit of results
ignoredObjects List List of strings of names of objects be ignored in the Queries for example : http://dbpedia.org/resource/thing
ignoredProperties List List of strings of names of properties to be ignored in the Queries
avoidCycles int Integer value which indicates whether we want to suppress cycles , 0 = no cycle avoidance , 1 = no intermediate object can be object1 or object2 , 2 = like 1 + an object can not occur more than once in a connection
Résultat List
        public List<InnerQuery> buildQueries(string object1, string object2, int maxDistance, int limit, List<string> ignoredObjects = null, List<string> ignoredProperties = null, int avoidCycles = 0)
        {
            List<InnerQuery> Queries = new List<InnerQuery>();
            Dictionary<int, List<InnerQuery>> Queries2 = getQueries(object1, object2, maxDistance, limit, ignoredObjects, ignoredProperties, avoidCycles);

            // Queries2 object  Dictionary<int,list<innerQuery>>  , interation over all the Queries
            foreach (int key in Queries2.Keys)
            {
                List<InnerQuery> arr = Queries2[key];

                //adding all Queries into a list of InnerQuery
                if (arr.Count > 0)
                {
                    for (int i = 0; i < arr.Count; i++)
                    {
                        Queries.Add(arr[i]);
                    }
                }
            }
            return Queries;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Builds and returns a set of queries to find relations between two object1 and object2.
        /// </summary>
        /// <param name="object1">object1</param>
        /// <param name="object2">object2</param>
        /// <param name="maxDistance">MaxiumDistance between the two objects</param>
        /// <param name="limit">Limit of results</param>
        /// <param name="ignoredObjects">List of strings of names of objects be ignored in the Queries</param>
        /// <param name="ignoredProperties">List of strings of names of properties to be ignored in the Queries</param>
        /// <param name="avoidCycles">Integer value which indicates whether we want to suppress cycles , 0 = no cycle avoidance ,  1 = no intermediate object can be object1 or object2 ,   2 = like 1 + an object can not occur more than once in a connection</param>
        /// <returns>false means an error happened, true means it's ok</returns>
        public bool generateQueries(string object1, string object2, int maxDistance = 3, int limit = 50, List <string> ignoredObjects = null, List <string> ignoredProperties = null, int avoidCycles = 1)
        {
            //here we reset everything because this method is only used upon new comparison
            //resetting the bool
            isEndOfResults = false;
            //resetting the list of queries
            generatedQueriesList = new List <SPARQLQueryBuilder.InnerQuery>();
            //resetting the resultlist
            curResultSet2 = new List <string>();
            //resetting the uniqueList of JsonObjects
            uniqueJsonObjects = new List <string>();

            //to make other methods see the two objects
            obj1 = object1;
            obj2 = object2;


            SPARQLQueryBuilder builder = new SPARQLQueryBuilder();

            //hardcoded objects to ignore (For testing purposes)
            ignoredObjects = new List <string>();
            ignoredObjects.Add("http://dbpedia.org/ontology/wikiPageWikiLink");
            ignoredObjects.Add("http://dbpedia.org/ontology/wikiPageRedirects");
            ignoredObjects.Add("http://www.w3.org/2002/07/owl#Thing");
            ignoredObjects.Add("http://www.opengis.net/gml/_Feature");


            generatedQueriesList = builder.buildQueries(object1, object2, maxDistance, limit, ignoredObjects, ignoredObjects, avoidCycles);
            //generatedQueriesList=builder.buildQueries(object1, object2, maxDistance, limit, ignoredObjects, ignoredProperties, avoidCycles);

            //if an error happened
            if (generatedQueriesList.Count < 1)
            {
                return(false);
            }

            return(true);
        }
All Usage Examples Of mergedServices.SPARQLQueryBuilder::buildQueries