Пример #1
0
        private static void SumOntologySummary(ref POCO.OntologyTermMatchResults parentResult, ref List <POCO.OntologyTermMatchResults> results)
        {
            // Make sure this term isn't referencing itself (this is allowed, but shouldn't try and look for any child terms)
            //if (parentResult.PartitionKey==parentResult.ParentTerm)
            //{
            //    return;
            //}

            int sumChildrenMatches = 0;

            // Find all the term matches with the same parent result and process
            for (int i = 0; i < results.Count; i++)
            {
                POCO.OntologyTermMatchResults childResult = results[i];
                // Check if the parent term matches our parent result
                if (childResult.ParentTerm == parentResult.RowKey)
                {
                    // Process children of this term
                    SumOntologySummary(ref childResult, ref results);

                    // Add the record association matches for this child to the sum
                    if (childResult.NumRecordAssociationMatches > 0)
                    {
                        bool hasRecordAssocMatches = true;
                    }
                    sumChildrenMatches += childResult.NumRecordAssociationMatches;
                }
            }

            // Update the sum for this item
            parentResult.NumRecordAssociationMatches += sumChildrenMatches;
        }
Пример #2
0
        public static List <POCO.OntologyTermMatchResults> GetOntologyMatchSummary(DataConfig providerConfig, POCO.OntologyAssigned ontologyAssigned)
        {
            // Get the ontology terms for this ontology
            List <POCO.OntologyTerm> oTerms = DataFactory.Ontology.GetOntologyTerms(providerConfig, ontologyAssigned);

            // Convert the ontology terms into match results
            List <POCO.OntologyTermMatchResults> results = new List <POCO.OntologyTermMatchResults>();

            foreach (POCO.OntologyTerm term in oTerms)
            {
                // Create a matching result object
                POCO.OntologyTermMatchResults result = new POCO.OntologyTermMatchResults();
                result.PartitionKey = term.PartitionKey;
                result.RowKey       = term.RowKey;
                result.Term         = term.Term;
                result.ParentTerm   = term.ParentTerm;
                results.Add(result);
            }

            // Get all the ontology term matches for this ontology
            List <POCO.OntologyTermMatch> termMatches = DataFactory.Ontology.GetOntologyTermMatches(providerConfig, ontologyAssigned.RowKey);

            foreach (POCO.OntologyTermMatch match in termMatches)
            {
                // Find the Term Match Result for this Term Match
                POCO.OntologyTermMatchResults matchedResult = results.Find(r => r.PartitionKey == match.PartitionKey && r.RowKey == match.TermRowKey);
                if (matchedResult != null)
                {
                    matchedResult.NumRecordAssociationMatches++;
                }
            }

            //TODO use Linq to select all the parent nodes instead
            // Walk the ontology tree and sum child counts to parent counts
            for (int i = 0; i < results.Count; i++)
            {
                POCO.OntologyTermMatchResults result = results[i];
                // Find a parent ontology term (which has no ParentTerm = OntologyUri (PartitionKey))
                if (result.ParentTerm == result.PartitionKey)
                {
                    // Recursively sum the child terms up to its parent
                    SumOntologySummary(ref result, ref results);
                }
            }

            return(results);
        }