Esempio n. 1
0
//-------------------------------------------------------------------------------
// General dumping methods -- dumping relevant parts of ontology
//-------------------------------------------------------------------------------
void TBox :: dump ( dumpInterface* dump ) const
{
	dump->prologue();

	// dump all (relevant) roles
	dumpAllRoles(dump);

	// dump all (relevant) concepts
	for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc )
		if ( isRelevant(*pc) )
			dumpConcept( dump, *pc );

	for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi )
		if ( isRelevant(*pi) )
			dumpConcept( dump, *pi );

	// dump GCIs
	if ( getTG() != bpTOP )
	{
		dump->startAx (diImpliesC);
		dump->dumpTop();
		dump->contAx (diImpliesC);
		dumpExpression ( dump, getTG() );
		dump->finishAx (diImpliesC);
	}

	dump->epilogue();
}
Esempio n. 2
0
void TBox :: buildDAG ( void )
{
	nNominalReferences = 0;

	// init concept indexing
	nC = 1;	// start with 1 to make index 0 an indicator of "not processed"
	ConceptMap.push_back(NULL);

	// make fresh concept and datatype
	concept2dag(pTemp);
	DLTree* freshDT = DTCenter.getFreshDataType();
	addDataExprToHeap ( static_cast<TDataEntry*>(freshDT->Element().getNE()) );
	deleteTree(freshDT);

	for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc )
		concept2dag(*pc);
	for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi )
		concept2dag(*pi);

	// init heads of simple rules
	for ( TSimpleRules::iterator q = SimpleRules.begin(), q_end = SimpleRules.end(); q < q_end; ++q )
		(*q)->bpHead = tree2dag((*q)->tHead);

	// builds Roles range and domain
	initRangeDomain(ORM);
	initRangeDomain(DRM);

	// build all splits
	for ( TSplitVars::iterator s = getSplits()->begin(), s_end = getSplits()->end(); s != s_end; ++s )
		split2dag(*s);

	RoleMaster::iterator p, p_end;

	// build all GCIs
	DLTree* GCI = Axioms.getGCI();

	// add special domains to the GCIs
	if ( likely(useSpecialDomains) )
		for ( p = ORM.begin(), p_end = ORM.end(); p < p_end; ++p )
			if ( !(*p)->isSynonym() && (*p)->hasSpecialDomain() )
				GCI = createSNFAnd ( GCI, clone((*p)->getTSpecialDomain()) );

	// take chains that lead to Bot role into account
	if ( !ORM.getBotRole()->isSimple() )
		GCI = createSNFAnd ( GCI,
				new DLTree ( TLexeme(FORALL), createRole(ORM.getBotRole()), createBottom() ) );

	T_G = tree2dag(GCI);
	deleteTree(GCI);

	// mark GCI flags
	GCIs.setGCI(T_G != bpTOP);
	GCIs.setReflexive(ORM.hasReflexiveRoles());

	// builds functional labels for roles
	for ( p = ORM.begin(), p_end = ORM.end(); p < p_end; ++p )
		if ( !(*p)->isSynonym() && (*p)->isTopFunc() )
			(*p)->setFunctional ( atmost2dag ( 1, *p, bpTOP ) );
	for ( p = DRM.begin(), p_end = DRM.end(); p < p_end; ++p )
		if ( !(*p)->isSynonym() && (*p)->isTopFunc() )
			(*p)->setFunctional ( atmost2dag ( 1, *p, bpTOP ) );

	// check the type of the ontology
	if ( nNominalReferences > 0 )
	{
		unsigned int nInd = i_end() - i_begin();
		if ( nInd > 100 && nNominalReferences > nInd )
			isLikeWINE = true;
	}

	// here DAG is complete; set its final size
	DLHeap.setFinalSize();
}
Esempio n. 3
0
void TBox :: gatherRelevanceInfo ( void )
{
	nRelevantCCalls = 0;
	nRelevantBCalls = 0;

	// gather GCIs features
	curFeature = &GCIFeatures;
	markGCIsRelevant();
	clearRelevanceInfo();
	KBFeatures |= GCIFeatures;

	// fills in nominal cloud relevance info
	NCFeatures = GCIFeatures;

	// set up relevance info
	for ( i_iterator pi = i_begin(); pi != i_end(); ++pi )
	{
		setConceptRelevant(*pi);
		NCFeatures |= (*pi)->posFeatures;
	}

	// correct NC inverse role information
	if ( NCFeatures.hasSomeAll() && !RelatedI.empty() )
		NCFeatures.setInverseRoles();

	for ( c_iterator pc = c_begin(); pc != c_end(); ++pc )
		setConceptRelevant(*pc);
	long cSize = ( c_end() - c_begin() ) + ( i_end() - i_begin() );
	size_t bSize = DLHeap.size()-2;

	curFeature = nullptr;

	float cRatio, bRatio = 0, logCSize = 1, logBSize = 1, sqCSize = 1, sqBSize = 1;
	if ( cSize > 10 )
	{
		cRatio = ((float)nRelevantCCalls)/cSize;
		sqCSize = sqrtf((float)cSize);
		if ( cSize > 1 )
			logCSize = logf((float)cSize);
	}
	if ( bSize > 20 )
	{
		bRatio = ((float)nRelevantBCalls)/bSize;
		sqBSize = sqrtf((float)bSize);
		if ( bSize > 1 )
			logBSize = logf((float)bSize);
	}

	if (0)	// relevance stat
	{
	if ( LLM.isWritable(llAlways) && cSize > 10 )
		LL << "There were made " << nRelevantCCalls << " relevance C calls for "
		   << cSize << " concepts\nRC ratio=" << cRatio << ", ratio/logSize="
		   << cRatio/logCSize << ", ratio/sqSize=" << cRatio/sqCSize << ", ratio/size="
		   << cRatio/cSize<< "\n";
	if ( LLM.isWritable(llAlways) && bSize > 20 )
		LL << "There were made " << nRelevantBCalls << " relevance B calls for "
		   << bSize << " nodes\nRB ratio=" << bRatio << ", ratio/logSize="
		   << bRatio/logBSize << ", ratio/sqSize=" << bRatio/sqBSize << ", ratio/size="
		   << bRatio/bSize << "\n";
	}

	// set up GALEN-like flag; based on r/n^{3/2}, add r/n^2<1
	isLikeGALEN = (bRatio > sqBSize*20) && (bRatio < bSize);

	// switch off sorted reasoning iff top role appears
	if ( KBFeatures.hasTopRole() )
		useSortedReasoning = false;
}