public function add_rel($params) { $res = addRelation($params["id"], $params["child_id"], $params["rel_id"]); $this->logPerson($params, 2); return $res; }
foreach (['children', 'parents', 'tokens', 'children_to_parents'] as $table) { $query = $db->createQueryBuilder(); $query->delete($table)->execute(); // $db->fetchAll('DELETE FROM ' . $table ); } //$db->delete('children', []); //$db->delete('parents', []); //$db->delete('tokens', []); //$db->delete('children_to_parents', []); $childrens = [Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'TestChildren']), Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'Children' . uniqid()])]; saveAll($childrens); $parents = [Parents::createObj(['login' => 'Parent' . uniqid(), 'password' => uniqid()]), Parents::createObj(['login' => 'TestParent', 'password' => 'ParentPass']), Parents::createObj(['login' => 'Parent' . uniqid(), 'password' => uniqid()]), Parents::createObj(['login' => 'Parent' . uniqid(), 'password' => uniqid()])]; saveAll($parents); $tokens = addTokens($parents); saveAll($tokens); addRelation($parents, $childrens); function addTokens($parents) { $tokens = []; foreach ($parents as $parent) { $tokens[] = Tokens::createObj(['parent_id' => $parent->id, 'token' => uniqid('token-'), 'type' => rand(0, 1)]); } return $tokens; } function saveAll(array $collection) { foreach ($collection as $el) { $el->save(); } } function addRelation(array $parents, array $childrens)
function flushProperRelations(&$relationsArr, &$conceptsArr, &$verb, &$lastSubject, $ssPoSPattern, &$filledConcepts) { if (count($conceptsArr) >= 2) { if (empty($verb)) { $verb = "n/a"; } if ($conceptsArr[0] != $conceptsArr[1]) { $type = "NON-TAXONOMIC"; addRelation($relationsArr, $type, $conceptsArr[0], $verb, $conceptsArr[1], $ssPoSPattern); if (count($conceptsArr) > 2) { addRelation($relationsArr, $type, $conceptsArr[1], "n/a", $conceptsArr[2], $ssPoSPattern); addRelation($relationsArr, $type, $conceptsArr[0], "n/a", $conceptsArr[2], $ssPoSPattern); } } $conceptsArr = array(); $verb = null; $filledConcepts = 0; } if (count($conceptsArr) == 1 && !empty($verb) && !empty($lastSubject) && $conceptsArr[0] != $lastSubject) { //echoN("||||".$conceptsArr[0]."|".$lastSubject); $temp = $conceptsArr[0]; $conceptsArr[0] = $lastSubject; $conceptsArr[1] = $temp; // many problems if ($conceptsArr[0] != $conceptsArr[1]) { $type = "NON-TAXONOMIC"; addRelation($relationsArr, $type, $conceptsArr[0], $verb, $conceptsArr[1], $ssPoSPattern); } $conceptsArr = array(); $verb = null; $filledConcepts = 0; } }
function rollBackRelation( $rollBackAction, $relationId, $firstMeaningId, $relationTypeId, $secondMeaningId, $operation ) { if ( shouldRemove( $rollBackAction, $operation ) ) { removeRelationWithId( $relationId ); } elseif ( shouldRestore( $rollBackAction, $operation ) ) { addRelation( $firstMeaningId, $relationTypeId, $secondMeaningId ); } }
public function add( IdStack $idPath, $record ) { $objectId = $this->objectIdFetcher->fetch( $idPath->getKeyStack() ); $definedMeaningAttributeId = $this->determineAttributeId( $idPath, "DM", $record->relationType ); $definedMeaningValue = $record->otherDefinedMeaning; if ( $definedMeaningAttributeId != 0 && $definedMeaningValue != 0 ) { addRelation( $objectId, $definedMeaningAttributeId, $definedMeaningValue ); } }
public function addEntry( SwissProtEntry $entry, $proteinMeaningId, $organismSpecificGene, $organismSpeciesMeaningId ) { $definedMeaningId = $this->addOrganismSpecificProtein( $entry->protein->name, $entry->organism, $proteinMeaningId, $organismSpecificGene, $organismSpeciesMeaningId ); // change name to make sure it works in wiki-urls: $swissProtExpression = str_replace( '_', '-', $entry->name ); addSynonymOrTranslation( $swissProtExpression, $this->languageId, $definedMeaningId, true ); foreach ( $entry->protein->synonyms as $key => $synonym ) addSynonymOrTranslation( $synonym, $this->languageId, $definedMeaningId, true ); addDefinedMeaningToCollection( $definedMeaningId, $this->collectionId, $entry->accession ); // add the comment fields as text attributes to the entry and link comments with // the appropriate definedMeaning $this->addComments( $entry, $definedMeaningId, $proteinMeaningId, $organismSpeciesMeaningId ); // add EC number: if ( $entry->EC != "" ) { $ECNumberMeaningId = $this->getOrCreateECNumberMeaningId( $entry->EC ); addRelation( $definedMeaningId, $this->activityConceptId, $ECNumberMeaningId ); } // add keywords: // foreach ($entry->keywords as $key => $keyword) { // if (array_key_exists($keyword, $this->keyword2GoMeaningIdMapping)) { // $goMeaningId = $this->keyword2GoMeaningIdMapping[$keyword]; // addRelation($definedMeaningId, $this->keywordConceptId, $goMeaningId); // } // } foreach ( $entry->GOReference as $key => $goReference ) { $relationConcept = 0; switch( $goReference->type ) { case "biological process": $relationConcept = $this->biologicalProcessConceptId; break; case "molecular function": $relationConcept = $this->molecularFunctionConceptId; break; case "cellular component": $relationConcept = $this->cellularComponentConceptId; break; } if ( $relationConcept != 0 ) addRelation( $definedMeaningId, $relationConcept, $this->goCollection->getOrCreateMember( $goReference->goCode ) ); } // Add 'included' functional domains: foreach ( $entry->protein->domains as $key => $domain ) { $domainMeaningId = $this->addFunctionalDomain( $domain ); foreach ( $domain->synonyms as $domainKey => $synonym ) addSynonymOrTranslation( $synonym, $this->languageId, $domainMeaningId, true ); addRelation( $definedMeaningId, $this->consistsOfId, $domainMeaningId ); } // Add 'contained' proteins: foreach ( $entry->protein->components as $key => $component ) { $componentMeaningId = $this->addContainedProtein( $component, $entry->organism, $organismSpeciesMeaningId ); foreach ( $component->synonyms as $componentKey => $synonym ) addSynonymOrTranslation( $synonym, $this->languageId, $componentMeaningId, true ); addRelation( $definedMeaningId, $this->containsConceptId, $componentMeaningId ); } return $definedMeaningId; }
function importSemanticTypeRelations( $collectionId, $relationCollectionContents, $query ) { global $db; $queryResult = mysql_query( $query, $db ); while ( $relation = mysql_fetch_row( $queryResult ) ) { $relationType = $relation[1]; $definedMeaningId1 = getDefinedMeaningFromCollection( $collectionId, $relation[0] ); $definedMeaningId2 = getDefinedMeaningFromCollection( $collectionId, $relation[2] ); $relationMeaningId = $relationCollectionContents[$relationType]; if ( !$relationMeaningId ) { echo "Unknown relation $relationType\n"; print_r( $relationCollectionContents ); print_r( $relation ); } if ( !$definedMeaningId1 ) { echo "Unknown semantic type $relation[0]\n"; print_r( $relation ); } if ( !$definedMeaningId2 ) { echo "Unknown semantic type $relation[2]\n"; print_r( $relation ); } if ( $definedMeaningId2 > 0 && $definedMeaningId1 > 0 && $relationMeaningId > 0 ) addRelation( $definedMeaningId2, $relationMeaningId, $definedMeaningId1 ); } }
if ($synonym != $parentConceptName) { $enrichedFinalConcepts[$finalConceptName]['EXTRA']['AKA']['EN']['WORDNET'] = cleanWordnetCollocation($synonym); } } } else { //echoN("##$finalConceptName|T-BOX"); //echoN("$concept,$is_a_relation_name_ar,$finalConceptName"); /* * WILL NOT DO IT HERE SINCE SOME RELATIONS ARE EXCLUDED LATER, SO OPERATIONS DONE HERE * CAN'T BE REVERTED BACK, WILL BE MOVED AFTER EXCLUSION INSTEAD */ //$enrichedFinalConcepts[$finalConceptName]['CONCEPT_TYPE']='T-BOX'; } echoN("XPP: 2 {$finalConceptName}"); $relationType = "TAXONOMIC"; $res = addRelation($relationsArr, $relationType, $concept, "{$is_a_relation_name_ar}", $finalConceptName, "{$is_a_relation_name_en}"); if ($res == true) { $newRelationsAdded++; } } } } } //if ( $conceptsEnriched>3) break; } echoN("Concepts Enriched from (WORDNET):{$conceptsEnriched}"); echoN("New Concepts Added:{$newConceptsAdded}"); echoN("New Relations Added:{$newRelationsAdded}"); preprint_r($newConceptsAddedArr); //preprint_r($enrichedFinalConcepts);exit; file_put_contents("{$ONTOLOGY_EXTRACTION_FOLDER}/temp.final.concepts.stage6", serialize($enrichedFinalConcepts));