Betrete \"$function_name\". Level=$debug_level"; }*/ /* define("PRESENT_TENSE",'PRESENT_TENSE'); define("PAST_TENSE",'PAST_TENSE'); //define("PERFECT_TENSE",'PERFECT_TENSE'); define("PRESENT_PERFECT_TENSE",'PRESENT_PERFECT_TENSE'); define("PAST_PERFECT_TENSE",'PAST_PERFECT_TENSE'); define("CONTNUOUS") */ function mysql_query_2($sql) { GLOBAL $con; deby( "
" . $sql . "
"); $result = mysql_query($sql,$con); deby( mysql_error()); return $result; } /* function process_command($input) { $command = explode(":",$input); if (sizeof($command) == 1) return false; switch ($command[0]) { case $TEXT_VERB: { $sql = "INSERT INTO words"; } } }*/ function output_debug($text) { global $debug; if ($debug) $_SESSION['form'] .= $text; } function output($text) { $_SESSION['form'] .= $text; } function reset_output() { $_SESSION['form'] = ""; } function get_stem_of_verb_third_person($version,$word) { switch ($version) { case 1: if (substr($word,-1)=="s") return substr($word,0,-1); break; case 2: if (substr($word,-2)=="es") { $stem = substr($word,0,-2); $end1 = substr($stem,-1); $end2 = substr($stem,-2); if ($end1=="s" || $end1=="z" || $end1=="x" || $end2=="ch" || $end2=="sh") return $stem; if ($end1=="i" && !is_vocal(substr($end2,0,1))) return substr($stem,0,-1) . "y"; } } return false; } function get_stem_of_verb_past_tense($version,$word) { switch ($version) { case 1: if (substr($word,-2)=="ed") return substr($word,0,-1); break; case 2: if (substr($word,-2)=="ed") { $stem = substr($word,0,-2); $end1 = substr($stem,-1); if ($end1=="i") $stem = substr($stem,0,-1) . "y"; return $stem; } break; case 3: if (substr($word,-2)=="ed") { $stem = substr($word,0,-2); $end1 = substr($stem,-1,1); $end2 = substr($stem,-2,1); $end3 = substr($stem,-3,1); if ($end1==$end2 && !is_vocal($end1) && is_vocal($end3)) if (sizeof($stem)<=8) return substr($stem,0,-1); } } return false; } /* function get_stem_of_verb_past_tense_double_consonant($version,$word) { if (substr($word,-2)=="ed") { $stem = substr($word,0,-2); $end1 = substr($stem,-1,1); $end2 = substr($stem,-2,1); $end3 = substr($stem,-3,1); if ($end1==$end2 && !is_vocal($end1) && is_vocal($end3)) if (sizeof($stem)<=8) return substr($stem,0,-1); } return false; }*/ function get_stem_of_verb_continuous($version,$word) { switch ($version) { case 1: if (substr($word,-3)=="ing") return substr($word,0,-3); break; case 2: if (substr($word,-3)=="ing" && !is_vocal(substr($word,-4,1))) return substr($word,0,-3) . "e"; } return false; } function is_vocal($letter) { return in_array($letter,array('a','e','i','o','u')); } function get_stem_of_noun($version,$word) { switch ($version) { case 2: if (substr($word,-3)=="ves") return substr($word,0,-3) . "f"; case 1: return get_stem_of_verb_third_person($version,$word); } return false; } function get_stem_of_adjective($version,$word) { switch ($version) { case 1: if (substr($word,-2)=="ly") { $stem = substr($word,0,-2); $end1 = substr($stem,-1); if ($end1=='i') $stem = substr($stem,0,-1) . 'y'; return $stem; } break; case 2: if (substr($word,-2)=="ly" && !is_vocal(substr($word,-3,1))) return substr($word,0,-2) . 'le'; break; case 3: if (substr($word,-3)=="lly") return substr($word,0,-1); break; case 4: if (substr($word,-6)=="ically") return substr($word,0,-4); } return false; } function query_word_by_id($word_id) { if ($word_id == 0) return ""; $sql = "SELECT * FROM words WHERE word_id=$word_id"; $result = mysql_query_2($sql); return mysql_fetch_array($result); } function search_word_in_word_table($word,$mask=0,$value=0,$new_type_clear=0,$new_type_set=0) { $sql = "SELECT * FROM words WHERE name='$word' AND (type & $mask)=$value"; $result = mysql_query_2($sql); if ($row = mysql_fetch_array($result)) $row['type'] = ($row['type'] & (~ $new_type_clear)) | $new_type_set; return $row; } function insert_new_word_in_word_table($name,$type,$stem_id=0,$number=0) { if ($stem_id) $sql = "INSERT INTO words (name,type,stem_id,date) VALUES ('$name',$type,'$stem_id',CURRENT_TIMESTAMP)"; else $sql = "INSERT INTO words (name,type,date) VALUES ('$name',$type,CURRENT_TIMESTAMP)"; mysql_query_2($sql); } /* function get_word_id($word) { if ($row = search_word_in_word_table($word)) return $row['word_id']; else return 0; }*/ $VERB_MASK = $WORD_TYPE_BIT['verb'] | $WORD_TYPE_BIT['verb_infinitive'] | $WORD_TYPE_BIT['verb_irregular']; // | $WORD_TYPE_BIT['verb_double_last_consonant_in_past_tense']; $VERB_STEM = $WORD_TYPE_BIT['verb'] | $WORD_TYPE_BIT['verb_infinitive']; $standard_conjugation_checking = array( array("versions" => array(1,2), "function" => "get_stem_of_verb_third_person", "mask" => $VERB_MASK, "stem" => $VERB_STEM, "type" => $WORD_TYPE_BIT['verb'] | $WORD_TYPE_BIT['verb_third_person'], "class_info" => "verb", "stem_info" => "to stem"), array("versions" => array(1,2,3), "function" => "get_stem_of_verb_past_tense", "mask" => $VERB_MASK, "stem" => $VERB_STEM, "type" => $WORD_TYPE_BIT['verb'] | $WORD_TYPE_BIT['verb_past_tense'] | $WORD_TYPE_BIT['verb_present_perfect_tense'], "class_info" => "verb", "stem_info" => "to stem"), /* array("versions" => array(1), "function" => "get_stem_of_verb_past_tense_double_consonant", "mask" => $VERB_MASK, "stem" => $VERB_STEM, "type" => $WORD_TYPE_BIT['verb'] | $WORD_TYPE_BIT['verb_past_tense'] | $WORD_TYPE_BIT['verb_double_last_consonant_in_past_tense'], "class_info" => "verb", "stem_info" => "to stem"), */ array("versions" => array(1,2), "function" => "get_stem_of_verb_continuous", "mask" => $VERB_MASK, "stem" => $VERB_STEM, "type" => $WORD_TYPE_BIT['verb'] | $WORD_TYPE_BIT['verb_continuous'], "class_info" => "verb", "stem_info" => "to stem"), array("versions" => array(1,2), "function" => "get_stem_of_noun", "mask" => $WORD_TYPE_BIT['noun'] | $WORD_TYPE_BIT['noun_singular'] | $WORD_TYPE_BIT['noun_irregular'] | $WORD_TYPE_BIT['noun_proper'], "stem" => $WORD_TYPE_BIT['noun'] | $WORD_TYPE_BIT['noun_singular'], "type" => $WORD_TYPE_BIT['noun'] | $WORD_TYPE_BIT['noun_plural'], "class_info" => "noun", "stem_info" => "the stem"), array("versions" => array(1,2,3,4), "function" => "get_stem_of_adjective", "mask" => $WORD_TYPE_BIT['adjective'] | $WORD_TYPE_BIT['adverb'] | $WORD_TYPE_BIT['adjective_irregular'], "stem" => $WORD_TYPE_BIT['adjective'], "type" => $WORD_TYPE_BIT['adverb'], "class_info" => "adjective", "stem_info" => "a stem thing") ); function get_word($word) { global $WORD_TYPE_BIT,$standard_conjugation_checking; $word_list = array(); //$row = search_word_in_word_table($word); $result = query_word($word); while ($row = mysql_fetch_array($result)) { if ($row['stem_id']) { //$row['stem'] = query_word_by_id($row['stem_id']); $parent = $row; //$type = $row['type']; $row = query_word_by_id($row['stem_id']); $row['type'] = $parent['type']; $row['parent_id'] = $parent['word_id']; $row['parent_name'] = $parent['name']; } $word_list[] = $row; } foreach ($standard_conjugation_checking as $item) { foreach ($item['versions'] as $version) if ($stem = $item['function']($version,$word)) { $row = search_word_in_word_table($stem,$item['mask'],$item['stem'],$item['mask'],$item['type']); if ($row) $word_list[] = $row; } } return $word_list; } /* function prepare_input($input) { $input = trim($input); }*/ /* function radio_button_word($type,$name,$value,$first_column,$second_column,$stem="") { $form .= "$first_column$second_column"; if ($stem != "") $form .= "$stem "; $form .= "" . $word . "
"; $form .= 'Type | Example | Stem | |||
noun: | the $word | ||||
noun plural: | many $word | the | |||
noun (proper): | $word | ||||
verb: | to $word | ||||
verb: | it $word | to | |||
verb: | $word is | to | |||
verb: | it $word yesterday | to | |||
verb: | it has $word | to | |||
adjective: | a $word thing | ||||
adverb: | doint it $word | a thing | |||
adverb: | doing it $word |
preposition: | of, with |
postposition: | ago |
conjunction: | and, but |
particle: | if, then |
question particle: | what |
modal verb: | can, must |
relative pronoun: | who |
article: | a, the |
pronoun: | he, she |
synthetical word: | _relative_ |
id | name | type | stem | date |
" . $word['word_id'] . " | " . "" . $word['name'] . " | " . "" . clear_text_word_type($word['type']) . " | " . "" . $word['stem_id'] . " | " . "" . $word['date'] . " | " . "
" . $sentence[$position]['raw_word'] . "
"; $text = print_word_list_open(); foreach ($sentence[$position]['word'] as $word) $text .= print_word_list($word); return $text . print_word_list_close(); } function print_word_of_word_table($word) { $result = query_word($word); $text = print_word_list_open(); while ($row = mysql_fetch_array($result)) { $text .= print_word_list($row); } return $text . print_word_list_close(); } //$last_selected_word_id = 0; function word_type_checking(&$word_list,$flag,$mark_word=false) { //foreach ($word_list as $word) for ($c=0; $c < sizeof($word_list); $c++) { if ($word_list[$c]['type'] & $flag) { if ($mark_word) $word_list[$c]['selected'] = true; return true; } } return false; } function word_name_checking(&$word_list,$names,$mark_word=false) { for ($c=0; $c < sizeof($word_list); $c++) { if (in_array($word_list[$c]['name'],$names)) { if ($mark_word) $word_list[$c]['selected'] = true; return true; } } return false; } function is_preposition(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['preposition'],$mark_word); } function is_particle(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['particle'],$mark_word); } function is_noun(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['noun'],$mark_word); } function is_verb(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['verb'],$mark_word); } function is_verb_continuous(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['verb_continuous'],$mark_word); } function is_verb_perfect_tense(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['verb_present_perfect_tense'],$mark_word); } function is_verb_past_tense(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['verb_past_tense'],$mark_word); } function is_verb_infinitive(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['verb_infinitive'],$mark_word); } function is_modal_verb(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['modal_verb'],$mark_word); } function is_relative_pronoun(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['relative_pronoun'],$mark_word); } function is_conjunction(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['conjunction'],$mark_word); } function is_question_particle(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['question_particle'],$mark_word); } function is_adjective(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['adjective'],$mark_word); } function is_adverb(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['adverb'],$mark_word); } function is_article(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['article'],$mark_word); } function is_synthetical_word(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['synthetical_word'],$mark_word); } /* function is_article(&$word_list,$mark_word=false) { return word_name_checking($word_list,array(WORD_A,WORD_AN,WORD_THE),$mark_word); }*/ function is_number(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['number'],$mark_word); } function is_variable(&$word_list,$mark_word=false) { global $WORD_TYPE_BIT; return word_type_checking($word_list,$WORD_TYPE_BIT['variable'],$mark_word); } function is_do(&$word_list,$mark_word=false) { global $WORD; return word_name_checking($word_list,array(WORD_DO),$mark_word); // return word_name_checking($word_list,array(WORD_DO,WORD_DOES,WORD_DID),$mark_word); } function is_auxiliary_verb(&$word_list,$mark_word=false) { return word_name_checking($word_list,array(WORD_HAVE,WORD_BE,WORD_DO),$mark_word); } function is_have(&$word_list,$mark_word=false) { global $WORD; return word_name_checking($word_list,array(WORD_HAVE),$mark_word); // return word_name_checking($word_list,array(WORD_HAVE,WORD_HAS,WORD_HAD),$mark_word); } function is_be(&$word_list,$mark_word=false) { global $WORD; return word_name_checking($word_list,array(WORD_BE),$mark_word); //return word_name_checking($word_list,array(WORD_IS,WORD_BE,WORD_BEEN,WORD_BEING),$mark_word); } function is_will(&$word_list,$mark_word=false) { global $WORD; return word_name_checking($word_list,array(WORD_WILL),$mark_word); //return word_name_checking($word_list,array(WORD_IS,WORD_BE,WORD_BEEN,WORD_BEING),$mark_word); } function is_would(&$word_list,$mark_word=false) { global $WORD; return word_name_checking($word_list,array(WORD_WOULD),$mark_word); //return word_name_checking($word_list,array(WORD_IS,WORD_BE,WORD_BEEN,WORD_BEING),$mark_word); } function is_and(&$word_list,$mark_word=false) { global $WORD; return word_name_checking($word_list,array(WORD_AND),$mark_word); } function is_pullstop(&$word_list,$mark_word=false) { global $WORD; return word_name_checking($word_list,array(CHAR_POINT),$mark_word); } function is_verb_selected(&$sentence,$position) { global $WORD_TYPE_BIT; $word = get_selected_word($sentence[$position]['word']); return $word['type'] & $WORD_TYPE_BIT['verb']; } function is_string_selected(&$sentence,$position) { global $WORD_TYPE_BIT; $word = get_selected_word($sentence[$position]['word']); return $word['type'] & $WORD_TYPE_BIT['string']; } function is_general_noun_selected(&$sentence,$position) { global $WORD_TYPE_BIT; $word = get_selected_word($sentence[$position]['word']); return ($word['type'] & ($WORD_TYPE_BIT['noun'] | $WORD_TYPE_BIT['noun_proper'])) == $WORD_TYPE_BIT['noun']; } function is_preposition_selected(&$sentence,$position) { global $WORD_TYPE_BIT; $word = get_selected_word($sentence[$position]['word']); return $word['type'] & $WORD_TYPE_BIT['preposition']; } function is_noun_or_gerund_selected(&$sentence,$position) { global $WORD_TYPE_BIT; $word = get_selected_word($sentence[$position]['word']); return ($word['type'] & $WORD_TYPE_BIT['noun']) || isset($sentence[$position]['gerund']); } function is_noun_selected(&$sentence,$position) { global $WORD_TYPE_BIT; $word = get_selected_word($sentence[$position]['word']); return ($word['type'] & $WORD_TYPE_BIT['noun']); } function get_tense_selected_word(&$word_list) { global $WORD_TYPE_BIT; $word = get_selected_word($word_list); // if ($word['type'] & $WORD_TYPE_BIT['verb_infinitive'] || $word['type'] & $WORD_TYPE_BIT['verb_third_person']) // return 'present'; /* function get_tense($word) {*/ if ($word['type'] & $WORD_TYPE_BIT['verb_past_tense']) return 'past'; if ($word['type'] & $WORD_TYPE_BIT['verb_present_perfect_tense']) return 'perfect'; return 'present'; } /* function unselect_word(&$sentence,$position) { for ($c=0; $c < sizeof($sentence[$position]['word']); $c++) unset($sentence[$position]['word'][$c]['selected']); } function get_word_id_depending_on_type(&$sentence,$position,$flag) { $word_list = $sentence[$position]['word']; for ($c=0; $c < sizeof($word_list); $c++) if ($word_list[$c]['type'] & $flag) return $word_list[$c]['word_id']; } function get_verb_word_id(&$sentence,$position) { global $WORD_TYPE_BIT; return get_word_id_depending_on_type($sentence,$position,$WORD_TYPE_BIT['verb']); } function get_verb_word_id(&$sentence,$position) { global $WORD_TYPE_BIT; return get_word_id_depending_on_type($sentence,$position,$WORD_TYPE_BIT['verb']); } */ /* function is_selected_verb_continuous(&$word_list) { global $WORD_TYPE_BIT; $word = get_selected_word($word_list); return $word['type'] & $WORD_TYPE_BIT['verb_continuous']; } */ /* function is_selected_verb_perfect_tense(&$word_list) { global $WORD_TYPE_BIT; $word = get_selected_word($word_list); return $word['type'] & $WORD_TYPE_BIT['verb_present_perfect_tense']; }*/ function is_selected_verb_infinitive(&$word_list) { global $WORD_TYPE_BIT; $word = get_selected_word($word_list); return $word['type'] & $WORD_TYPE_BIT['verb_infinitive']; } function get_child(&$sentence,$position,$l_type,$raw_word=false) { //echo print_sentence_detailed($sentence); for ($c=0; $c < sizeof($sentence); $c++) { if (isset($sentence[$c]['l_value'])) if ($sentence[$c]['l_value']==$position && $sentence[$c]['l_type']==$l_type) if ($raw_word) { if ($sentence[$c]['raw_word']==$raw_word) return $c; } else return $c; } return INVALID_POSITION; } function get_referring_child(&$sentence,$position) { for ($c=0; $c < sizeof($sentence); $c++) { if (isset($sentence[$c]['l_value']) && isset($sentence[$c]['reference']) && $sentence[$c]['l_value']==$position) return $sentence[$c]['reference']; } return INVALID_POSITION; } function get_reference_child(&$sentence,$position) { for ($c=0; $c < sizeof($sentence); $c++) if (isset($sentence[$c]['l_value']) && isset($sentence[$c]['reference'])) if ($sentence[$c]['l_value'] == $position) return $sentence[$c]['reference']; return INVALID_POSITION; } /* function get_child_including_reference(&$sentence,$position,$l_type) { //echo print_sentence_detailed($sentence); for ($c=0; $c < sizeof($sentence); $c++) { if (isset($sentence[$c]['l_value'])) if ($sentence[$c]['l_value']==$position && $sentence[$c]['l_type']==$l_type) return $c; if ($sentence[$c]['raw_word']==SYNTHETICAL_WORD_REFERENCE && ) } return INVALID_POSITION; } */ /* function is_verb_relative(&$sentence,$position) { if (get_child($sentence,$position,L_TYPE,SYNTHETICAL_WORD__RELATIVE_L_VALUE) == INVALID_POSITION) return false; else return true; }*/ /* function decode_input($word) { if ($word[$word_position]['type']==$WORD_TYPE_NOUN) $sentence_status[$sentence_level] = "await subject"; switch ($current_word_type) { case "noun": { $subject[$sentence_level][] = $current_word; $subject[$sentence_level][] } }*/ /*class sentence { */ /* public function make_brackets($sentence,$decision_sequence) { $sentence_clause = "ad_verb_1"; //$sentence_sub_part = "1"; $begin_read_clause $output[] = "("; $output[] = $sentence_part; $clause = ")"; } */ /* protected function read_adverbial_clause() { if ($input[$input_pos]['type'] == $WORD_TYPE_PREPOSITION) { $output[$output_pos++] = $BRACKET_OPEN; $output[$output_pos++] = $input[$input_pos++]; read_object_clause(); $output[$output_pos++] = $BRACKET_CLOSE; return true; } else return false } */ /* function read_adverbial_clause($sentence,$position) { if (isset($sentence[$position]) && $sentence[$position]['type'] == $WORD_TYPE['preposition']) { $position = read_object_clause($sentence,$position) } }*/ /* function seek_object_clause($sentence,$position) { if (isset($sentence[$position])) { if ($sentence[$position]['type'] == $WORD_TYPE['preposition']) { $position = read_object_clause($sentence,$position); } } } function get_clause($sentence,$position) { } */ /* function skim_adverbial_clause(&$sentence,$position,$size="max") { //global $WORD_TYPE; $position_start = $position; $error = false; while (1) { if (isset($sentence[$position])) { if (is_preposition($sentence[$position]['word'])) //($sentence[$position]['type'] == $WORD_TYPE['preposition']) { //position_interval = read_preposition_clause($sentence,$position,"min"); list($error,$pos,$anchor) = skim_object_clause($sentence,++$position,"min"); if ($error) break; //return array(false,$position_start,$position); $position = $pos; if ($size=="min") break; } else break; } else break; } if ($position_start==$position) $error = 'empty'; return array($error,$position); //array_slice($sentence,$position_start,$position)); } */ /* function skim_object_clause(&$sentence,$position,$level,$expect_noun=false,$size="max") { $sentence_2 = $sentence; return analyse_object_clause($sentence_2,$position,$level,$expect_noun,true,false); }*/ /* function skim_object_clause(&$sentence,$position,$size="max") { //global $WORD_TYPE; echo $position_start = $position; $error = false; while (1) { if (isset($sentence[$position])) { //$type = $sentence[$position]['type']; //if ($type == $WORD_TYPE['noun'] || $type == $WORD_TYPE['noun_plural'] || $type == $WORD_TYPE['noun_proper']) //$current_word = $sentence[$position]['word']; //if (is_noun($current_word) || is_adjective($current_word) || is_adverb($current_word)) list($error,$position) = skim_noun($sentence,$position); if (!$error) { //$position++; echo " -new pos after noun = " . $position; if ($size=="min") break; if (isset($sentence[$position]) && is_preposition($sentence[$position]['word'])) //$sentence[$position]['type'] == $WORD_TYPE['preposition']) { //list ($error,$pos) = skim_object_clause($sentence,++$position,$size); // //list ($error,$pos) = skim_adverb_clause($sentence,$position,$size); $position++; echo "mhm " . $error; if ($error) break; //echo "--" . $position = $pos; } else break; } else break; } else break; } if (!$error && $position_start==$position) echo $error = 'empty'; return array($error,$position); } */ function skim_verb_clause(&$sentence,$position,$question_verb=INVALID_POSITION) { $sentence_2 = $sentence; return analyse_verb_clause($sentence,$position,$question_verb,true); } function analyse_verb_clause(&$sentence,$position,$question_verb=INVALID_POSITION,$skim_mode=false,$l_value=INVALID_POSITION,$l_type=L_TYPE) { while (1) { list($error,$position,$anchor_verb,$gerund) = analyse_one_verb_clause($sentence,$position,$question_verb,$l_value,$l_type); break; // absichtlich kein "and" bei verb!! if ($error) break; $l_value = $position; list($error_and,$position) = analyse_and($sentence,$position,$anchor_verb,$skim_mode); if ($error_and) break; list($error,$position,$second_anchor_verb,$second_gerund) = analyse_verb_clause($sentence,$position,$question_verb,$skim_mode,$l_value,$l_type); break; } return array($error,$position,$anchor_verb,$gerund); } function analyse_one_verb_clause(&$sentence,$position,$question_verb=INVALID_POSITION,$l_value=INVALID_POSITION,$l_type=L_TYPE) { //global $WORD_TYPE; deby("error = " . $this->error . " in positions " . $this->position_start . " - " . $this->position . "
"; return $text; } } function analyse_sentence(&$sentence,$mode) { try { if (sizeof($sentence)==1 && $mode=='enter') { $error = glossary_maintenance($sentence); } else { if ($mode=='search') { if (false && check_for_question($sentence)) { list($error,$position,$anchor_verb,$gerund,$anchor_subject) = analyse_question($sentence); //$task = "answer"; } else { list($error,$position,$anchor_verb,$gerund,$anchor_subject) = analyse_assertion($sentence,0,0,false,false,INVALID_POSITION, false,true,INVALID_POSITION,true,INVALID_POSITION,false,true); } if (isset_primary_sentence_position($sentence,$position)) throw new sentence_exception('invalid extra words',0,$position); $save_sentence = $sentence; if (!$error) { print_decisions($sentence); output(answer_question($save_sentence)); } //refresh_statistics($sentence); } else { list($error,$position) //,$anchor_verb,$gerund,$anchor_subject) = analyse_input($sentence,0,0,false,false,INVALID_POSITION,false,true); //$task = "enter"; if (isset_primary_sentence_position($sentence,$position)) throw new sentence_exception('invalid extra words',0,$position); $save_sentence = $sentence; if (!$error) { //if ($mode=='enter') enter_sentence($save_sentence); refresh_statistics($save_sentence); print_decisions($sentence); } } //if (DEBUG_MODE) output_debug(print_sentence_detailed($save_sentence)); //if ($position < sizeof($sentence)) // if ($error=='decision') // output(print_sentence_alternatives($sentence)); /* if (!$error) { $text = "" . print_sentence_highlight_decided($sentence) . "
"; output($text); }*/ } } catch (sentence_exception $exception) { /* if ($exception->error=='decision') { deby(print_sentence_detailed($sentence)); //delete_synthetical_words($sentence); output("$position_second_object != $position_last_adverbial_clause
"); //if ($position_second_object != $position_last_adverbial_clause) if (!$error_second_object) throw new sentence_exception("unexpected second object given passive verb",$position,$position_second_object); $object = get_child($sentence,$anchor_verb,N_TYPE); //if (!$gerund_mode) if ($anchor_subject != INVALID_POSITION) { $sentence[$anchor_subject]['l_value'] = $anchor_verb; $sentence[$anchor_subject]['l_type'] = M_TYPE; } /* if ($object != INVALID_POSITION) { //$sentence[$object]['l_type'] = N_TYPE; // if (!$gerund_mode) // $sentence[$anchor_subject]['l_type'] = M_TYPE; } else */ if ($object == INVALID_POSITION) { //throw new sentence_exception("2 obj",$position,$position_second_object); // if (!$gerund_mode) if ($anchor_subject != INVALID_POSITION) $sentence[$anchor_subject]['l_type'] = N_TYPE; remove_to_from_dative_object($sentence,$anchor_verb); } $by_preposition = get_child($sentence,$anchor_verb,L_TYPE,WORD_BY); deby( "" . $label[1] . " | "; $sub_label = $label[1]; $label = $label[0]; } else { $text .= "" . $label . " | "; $sub_label = ""; } foreach ($sentence as $item) { $text .= "";
if ($label == 'pos')
$text .= $pos++;
/* if (sizeof($label)>1)
{
//$item = $item[$label[0]];
}
*/
else
if (isset($item[$label]))
{
if (sizeof($item[$label]) > 1)
{
$text .= "
| ";
}
$text .= "
start=$position_start, ende=$position, noun=$position_noun
"); return array($error,$position); } function analyse_article(&$sentence,$position) { if (isset_primary_sentence_position($sentence,$position) && is_article($sentence[$position]['word'],true)) { //if ($sentence[$position]['raw_word'] == WORD_AN) return array(false,$position+1); } else return array('empty',$position); } function link_noun_sequence(&$sentence,$position_start,$position_end) //,$set_end_value_in_anchor_noun=true) { for ($c=$position_start; $c < $position_end-1; $c++) { $sentence[$c]['l_value'] = $c+1; $sentence[$c]['l_type'] = NOUN_TYPE; } // unset($sentence[$position_end-1]['l_value']); // unset($sentence[$position_end-1]['l_type']); // if ($set_end_value_in_anchor_noun) set_l_value_end($sentence[$position_end-1]); } function slice_noun_sequence(&$sentence,$position_start,$position_end) { $length = $position_end-$position_start; $partial_sentence = array_slice($sentence,$position_start,$length); link_noun_sequence($partial_sentence,0,$length); return $partial_sentence; } function get_number_occurences_of_noun_sequence(&$sentence,$position_start,$position_end) { if ($position_end-$position_start > 1) { $noun_sequence = slice_noun_sequence($sentence,$position_start,$position_end); //$result = query_sentence($noun_sequence); //($sentence,$position_start,$c); //return mysql_num_rows($result); return statistically_query_sentence($noun_sequence); } return 0; } function analyse_noun_sequence(&$sentence,$position,$expect_noun=false,$skim_mode=false) { /* list($error,$position,$anchor_noun) = analyse_variable($sentence,$position); //,$l_value,$l_type); if (!$error) is_noun($sentence[$anchor_noun]['word'],true); else {*/ $position_start = $position; $error = false; //deby ("Betrachte noun sequence mit" . isset($sentence[$position_start]['no_machine_decision_noun_sequence'])); while (isset_primary_sentence_position($sentence,$position) && is_noun($sentence[$position]['word'],true)) { if (isset($sentence[$position]['stop_marker']) && !isset($sentence[$position_start]['no_machine_decision_noun_sequence'])) { // unset($sentence[$position]['stop_marker']); $position++; $stop_marker = true; break; //return array(false,$position,$position-1); } $position++; if (isset_primary_sentence_position($sentence,$position) && (is_verb($sentence[$position]['word']) || is_variable($sentence[$position]['word'])) ) break; } if (!isset($stop_marker)) { $number_nouns = $position-$position_start; if ($expect_noun && $number_nouns > 1) { // if ($number_nouns == 2) // $position--; // else { for ($c=$position_start+1; $c <= $position; $c++) { //$first_noun_sequence = slice_noun_sequence($sentence,$position_start,$c); //$second_noun_sequence = slice_noun_sequence($sentence,$c,$position); //echo print_r($second_noun_sequence); die(); // $number_occurences = 0; $number_of_occurences[$c-$position_start-1] = get_number_occurences_of_noun_sequence($sentence,$position_start,$c) + get_number_occurences_of_noun_sequence($sentence,$c,$position); } /* $noun_sequence = slice_noun_sequence($sentence,$position_start,$c); $result = query_sentence($first_noun_sequence); //($sentence,$position_start,$c); $number_occurences = mysql_num_rows($result); $result = query_sentence($second_noun_sequence); //($sentence,$c,$position); $number_of_occurences[$c] = mysql_num_rows($result) + $number_first_occurences; */ $pos = try_to_decide_by_probability($number_of_occurences); if ($pos == INVALID_POSITION && $skim_mode) $position = 0+$position_start+1; else if ($pos == INVALID_POSITION || isset($sentence[$position_start]['no_machine_decision_noun_sequence'])) { // if ($skim_mode) // $position = 0+$position_start+1; // else { unset($sentence[$position_start]['no_machine_decision_noun_sequence']); output_make_selection(); output(print_sentence_alternatives_noun($sentence,$position_start,$position)); throw new sentence_exception('decision noun',$position_start,$position); } } else $position = $pos+$position_start+1; } } } $anchor_noun = $position-1; link_noun_sequence($sentence,$position_start,$position); //,false); test_error_empty($error,$position_start,$position); // } return array($error,$position,$anchor_noun); } function analyse_noun_no_gerund(&$sentence,$position,$level,$expect_noun=false,$skim_mode=false) { $position_start = $position; $error = false; $position_last_verb_continuous = INVALID_POSITION; $gerund = false; /* list($error_article,$position) = skim_article($sentence,$position); if (!$error_article) $article_position = $position; else $article_position = INVALID_POSITION; */ while (1) { list($error_adjective,$position) = skim_adjective($sentence,$position,$level,$position_last_verb_continuous); if ($error_adjective) break; } if (isset_primary_sentence_position($sentence,$position) && is_noun($sentence[$position]['word'] /*,true*/)) { list($error,$position,$position_noun) = analyse_noun_sequence($sentence,$position,$expect_noun,$skim_mode); $position_last_verb_continuous = $position; //if ($position >=3) //echo "sssss " . $error . "#$position_start#$position
"); return array($error,$position_noun,$position); } function skim_noun_no_gerund(&$sentence,$position,$level,$expect_noun) { $sentence_2 = $sentence; return analyse_noun_no_gerund($sentence_2,$position,$level,$expect_noun,true); } /* function _alt_analyse_noun(&$sentence,$position,$level,$expect_noun=false,$skim_mode=false,$l_value=INVALID_POSITION,$expect_assertion=false) { while (1) { list($error,$anchor_noun,$position,$gerund) = analyse_one_noun($sentence,$position,$level,$expect_noun,$skim_mode,$l_value); if ($error) break; deby("bin an position $position mit $error"); if (isset($last_and)) link_and($sentence,$last_anchor_noun,$last_and,$anchor_noun); // unset($last_and); //deby("....." . print_sentence_detailed($sentence)); list($error_and,$position_next_noun) = analyse_and($sentence,$position); //deby("....." . print_sentence_detailed($sentence)); if ($error_and) break; deby(" found and"); if ($expect_assertion) { deby(""; $text .= print_sentence_highlighted($sentence,array($anchor_verb,$anchor_object)); $text .= "
"; return $text; } function print_sentence_alternatives(&$sentence,$and_mode=false,$child_l_type=M_TYPE,$anchor_noun=INVALID_POSITION, $anchor_verb=INVALID_POSITION) { // deby("" . print_sentence_highlight_preposition($sentence) . "
"; //return ""; $text .= "" . print_sentence_highlight_noun_sequence($sentence) . "
"; //return ""; $text .= "" . print_sentence_highlight_verb_and_object($sentence) . "
"; return $text; } function print_sentence_highlight_preposition($sentence) { //deby(print_sentence_detailed($sentence)); die(); $text = ""; $color_pointer = 0; $color_table = array("ff0000","00c000","0000ff","c0c000","8000c0","00c0c0","ff8000","60c0ff","00ff00","8040a0"); for ($c=0; $c < sizeof($sentence); $c++) { //if ($sentence[$c]['l_type'] != L_TYPE_DROP) { if (isset($sentence[$c]['decision'])) { //$l_value = get_l_value_skip_reference($sentence,$c); //$sentence[$c]['l_value']; $l_value = $sentence[$c]['decision']; if (!isset($sentence[$l_value]['anchor_color'])) $sentence[$l_value]['anchor_color'] = $color_table[$color_pointer++]; } } } // if (!in_array($l_value,$anchor_list)) // $anchor_list[] = $l_value; for ($c=0; $c < sizeof($sentence); $c++) { if (!isset_primary_sentence_position($sentence,$c)) break; //$decided = isset($sentence[$c]['decision']); $anchor = isset($sentence[$c]['anchor_color']); // $post_a_decided_word = isset($sentence[$c]['m_value']) && isset($sentence[$sentence[$c]['m_value']]['decision']) // || isset($sentence[$c]['n_value']) && isset($sentence[$sentence[$c]['n_value']]['decision']); // $post_a_decided_word = ($sentence[$c]['l_type']==M_TYPE || $sentence[$c]['l_type']==N_TYPE) // && isset($sentence[$sentence[$c]['l_value']]['decision']); //$decided = $decided || $post_a_decided_word; if ($anchor) { $anchor_color = $sentence[$c]['anchor_color']; $text .= ""; if ($url_text == "") $text .= $input_row['text']; else { $url_text = check_url($url_text); $text .= "" . $input_row['text'] . ""; } $text .= " | " . "delete | " . "alter | " . "
no result
"; } function query_sentence_row($sentence_id) { $sql = "SELECT * FROM sentences WHERE sentence_id=$sentence_id"; $result = mysql_query_2($sql); return mysql_fetch_array($result); } function query_sentence_childs($sentence_id) { $sql = "SELECT * FROM sentences WHERE l_value=$sentence_id"; return mysql_query_2($sql); // return mysql_fetch_array($result); } function query_word($word) { $sql = "SELECT * FROM words WHERE name='$word'"; return mysql_query_2($sql); /* $sql = "SELECT * FROM words WHERE word_id=$word_id"; $result = mysql_query_2($sql); return mysql_fetch_array($result); */ } /* function seek_sentence_start($sentence_id) { while (1) { if ($row=query_sentence_row($sentence_id)) { if ($row['l_type']==L_TYPE_END) return $row; $sentence_id = $row['l_value']; } else return false; } } */ function seek_sentence_start($sentence_row) { while (1) { if ($sentence_row['l_type']==L_TYPE_END) return $sentence_row; $sentence_row = query_sentence_row($sentence_row['l_value']); } } function read_sentence_tree($sentence_row) { return ""; $text = ""; $tree['row'] = $sentence_row; $tree['word'] = query_word_by_id($sentence_row['word_id']); //$text .= $tree['word']['name'] . " ( "; $text .= $tree['word']['name'] . "-" . $sentence_row['l_type'] . "( "; $result_childs = query_sentence_childs($sentence_row['sentence_id']); while ($child = mysql_fetch_array($result_childs)) { list($sub_tree,$sub_text) = read_sentence_tree($child); $tree['child'][] = $sub_tree; $text .= $sub_text; } $text .= " ) "; return array($tree,$text); } /* function print_sentence_tree($tree) { $text = ""; }*/ function get_url_text_of_input($input_row) { if (!$input_row['url']) return ""; return get_array_value(query_word_by_id($input_row['url']),'name'); } function get_input_text_of_sentence($sentence_row) { $input_id = $sentence_row['input_id']; $row = get_input_row($input_id); return $row; return array($input_id,$row['text'],query_word_by_id($row['url'])); $sentence_start = seek_sentence_start($sentence_row); if ($input_id = $sentence_start['l_value']) return get_array_value(get_input_row($input_id),'text'); else { list($tree,$text) = read_sentence_tree($sentence_row); return $text; } } function get_input_row($input_id) { $sql = "SELECT * FROM inputs WHERE input_id=$input_id"; return mysql_fetch_array(mysql_query_2($sql)); } function add_word_to_sentence(&$sentence,$word,$select_word=false) { $position = sizeof($sentence); $found_words = get_word($word); if ($select_word && sizeof($found_words)==1) $found_words[0]['selected'] = true; $sentence[$position] = array('word' => $found_words, 'raw_word' => $word); return $position; } function add_reference_word_to_sentence(&$sentence,$reference,$l_value=INVALID_POSITION,$l_type=L_TYPE_END) { $position = add_word_to_sentence($sentence,SYNTHETICAL_WORD_REFERENCE,true); $sentence[$position]['reference'] = $reference; $sentence[$position]['l_value'] = $l_value; $sentence[$position]['l_type'] = $l_type; return $position; } function isset_primary_sentence_position(&$sentence,$position) { if (isset($sentence[$position]) && !is_synthetical_word($sentence[$position]['word'])) // !isset($sentence[$position]['primary_sentence_stop_marker'])) return true; else return false; } function get_primary_sentence(&$sentence) { for ($c=0; $c < sizeof($sentence); $c++) if (!isset_primary_sentence_position($sentence,$c)) break; return array_slice($sentence,0,$c); } function delete_synthetical_words(&$sentence) { for ($c=sizeof($sentence); --$c >=0; ) if (!isset_primary_sentence_position($sentence,$c)) unset($sentence[$c]); } /* ALT: function mark_l_value_relative(&$sentence,$position) { $relative_pos = add_word_to_sentence($sentence,SYNTHETICAL_WORD__RELATIVE_L_VALUE,true); $sentence[$relative_pos]['l_value'] = $position; $sentence[$relative_pos]['l_type'] = L_TYPE; }*/ function glossary_maintenance(&$sentence) { //output(work_word($sentence[0]['raw_word'])); $word = $sentence[0]['raw_word']; $text = "These are the entries in the word table
"; $text .= print_word_of_word_table($word); $text .= "These are the possible interpretations
"; //"So the word may be interpreted";
$text .= list_word($sentence,0);
//$text .= "";
$text .= " Enter here an additional version if necessary
" . /*clear_text_word_type(*/$word['type'] ." ". $mask . " " .( $word['type'] & $mask) ." " . (8352 & 8224) ."
"; if (($word['type'] & $mask)==$type && $word['name']==$stem) return true; //} return false; } function enter_new_words(&$_post) { for ($c=0; $c < $_SESSION['unknown_words']; $c++) { if (isset($_post['word' . $c])) { //$stem_id = 0; $value = explode(":",$_post['word' . $c]); if (sizeof($value)>2) { list($word,$type,$index_stem,$mask_stem_type,$stem_type,$new_stem_type) = $value; $type = (int) $type; $mask_stem_type = (int) $mask_stem_type; $stem_type = (int) $stem_type; $new_stem_type = (int) $new_stem_type; $stem = $_post[$index_stem]; //if ($stem) { $row_stem = search_word_in_word_table($stem,$mask_stem_type,$stem_type); if (!$row_stem) { insert_new_word_in_word_table($stem,$new_stem_type); $stem_id = mysql_insert_id(); } else { output("Stem already exists.
"); $stem_id = $row_stem['word_id']; } deby( "Word already exists.
"); } /* // does_exist_word_in_word_table(); $row_word = search_word_in_word_table($value[0],-1,$value[1]); if (!$row_word) { if (sizeof($value)>2) { echo $stem = $_post[$value[2]]; if ($stem) { $row_stem = search_word_in_word_table($stem,$value[3],$value[4]); if (!$row_stem) { insert_new_word_in_word_table($stem,$value[5]); $stem_id = mysql_insert_id(); } else $stem_id = $row_stem['word_id']; echo "Entry of word already exists.
"); */ } } } function deby_die(&$sentence) { deby(print_sentence_detailed($sentence)); die(); } function deby($text) { global $debug; if ($debug) echo $text; } function check_correctness_of_sentence(&$sentence) { for ($c=0; $c < sizeof($sentence); $c++) if (!isset($sentence[$c]['l_value']) || !isset($sentence[$c]['l_type'])) throw new sentence_exception("such sentence constructions are still not allowed",0,$c); } function get_last_passive_participle(&$sentence,$position) { for ($c=$position; $c >= 0; $c--) if (isset($sentence[$c]['passive_participle'])) return $c; return INVALID_POSITION; } function get_sub_sentence_subject_predicate_object(&$sentence,$position) { $position_list[] = $position; $position_list[] = $sentence[$position]['l_value']; $position_list[] = get_child($sentence,$position,M_TYPE); $position_list[] = get_child($sentence,$position,N_TYPE); /* $position_list[] = $position; $position_list[] = skip_reference_word($sentence,$sentence[$position]['l_value']); $position_list[] = skip_reference_word($sentence,get_child($sentence,$position,M_TYPE)); $position_list[] = skip_reference_word($sentence,get_child(get_child($sentence,$position,N_TYPE)); */ // remove_refernce_words($sentence,$position_list); return pick_sub_sentence($sentence,$position_list); } /* function skip_reference_word(&$sentence,$position) { if (isset($sentence[$position]['reference'])) return $sentence[$position]['reference']; else return $position; }*/ /* function pick_sub_sentence(&$sentence,$positions) { print_r($positions); $new_position_pointer = 0; for ($c=0; $c < sizeof($positions); $c++) { $sub_sentence[$new_position_pointer] = $sentence[$positions[$c]]; $new_position[$positions[$c]] = $new_position_pointer++; if (isset($sentence[$positions[$c]]['reference'])) { $sub_sentence[$new_position_pointer] = $sentence[$sentence[$positions[$c]]['reference']]; $new_position[$sentence[$positions[$c]]['reference']] = $new_position_pointer++; } } for ($c=0; $c < sizeof($sub_sentence); $c++) { if (isset($new_position[$sub_sentence['l_value']])) $sub_sentence['l_value'] = $new_position[$sub_sentence['l_value']]; else $sub_sentence['l_value'] = INVALID_POSITION; } return $sub_sentence; }*/ function pick_sub_sentence(&$sentence,$positions) { //print_r($positions); foreach ($positions as $position) { if ($position != INVALID_POSITION) { $new_positions[] = $position; if (isset($sentence[$position]['reference'])) $new_positions[] = $sentence[$position]['reference']; } } $sub_sentence = $sentence; for ($c=0; $c < sizeof($sub_sentence); $c++) { if (in_array($c,$new_positions)) { if (!in_array($sub_sentence[$c]['l_value'],$new_positions)) $sub_sentence[$c]['l_value'] = INVALID_POSITION; } else set_l_value_drop($sub_sentence[$c]); } return $sub_sentence; } function is_likely_prepositon_associated_with_predicate($raw_word) { if ($raw_word==WORD_OF) return false; else return true; } function reset_sentence_for_reprocessing(&$sentence) { for ($c=0; $c < sizeof($sentence); $c++) if (isset_primary_sentence_position($sentence,$c)) { $new_sentence[$c]['word'] = $sentence[$c]['word']; $new_sentence[$c]['raw_word'] = $sentence[$c]['raw_word']; if (is_preposition($sentence[$c]['word'])) { if (isset($sentence[$c]['former_l_value'])) //$new_sentence[$c]['pre_decided_l_value'] = $sentence[$c]['former_l_value']; $new_sentence[$c]['l_value'] = $sentence[$c]['former_l_value']; else if (isset($sentence[$c]['l_value'])) //$new_sentence[$c]['pre_decided_l_value'] = $sentence[$c]['l_value']; $new_sentence[$c]['l_value'] = $sentence[$c]['l_value']; } //if (isset($sentence[$c]['anchor_verb'])) // $new_sentence[$c]['anchor_verb'] = $sentence[$c]['anchor_verb']; $save_labels = array('verb','stop_marker','number_of_objects','decision'); foreach ($save_labels as $label) if (isset($sentence[$c][$label])) $new_sentence[$c][$label] = $sentence[$c][$label]; /* if (isset($sentence[$c]['stop_marker'])) $new_sentence[$c]['stop_marker'] = $sentence[$c]['stop_marker']; if (isset($sentence[$c]['number_of_objects'])) $new_sentence[$c]['number_of_objects'] = $sentence[$c]['number_of_objects']; */ } $sentence = $new_sentence; //deby("LEIDER
"); if ($current_l_value == $predicate_of_object) {deby("" . $decisions_text . "
"; output($text); } } } function fusion_double_edges(&$sentence) { $sizeof_sentence = sizeof($sentence); for ($c1=0; $c1 < $sizeof_sentence; $c1++) { if ($sentence[$c1]['l_type'] != L_TYPE_DROP && $sentence[$c1]['l_value'] != INVALID_POSITION) { for ($c2=0; $c2 < $sizeof_sentence; $c2++) { if ($sentence[$c2]['l_type'] != L_TYPE_DROP && $sentence[$c2]['l_value'] != INVALID_POSITION) { $vertex1[0] = get_referred_position($sentence,$c1); $vertex1[1] = $sentence[$c1]['l_value']; $vertex2[0] = get_referred_position($sentence,$c2); $vertex2[1] = $sentence[$c2]['l_value']; $type1 = $sentence[$c1]['l_type']; $type2 = $sentence[$c2]['l_type']; if ($vertex1[1] == $vertex2[0]) { if (isset($sentence[$vertex2[0]]['preposition']) || is_verb_selected($sentence,$vertex2[1])) { $new_edge = add_reference_word_to_sentence($sentence,$vertex1[0],$vertex2[1],$type2); copy_preposition($sentence,$vertex2[0],$new_edge); } else { $new_edge = add_reference_word_to_sentence($sentence,$vertex1[0],$vertex2[1],$type1); copy_preposition($sentence,$c1,$new_edge); } } if (($vertex1[1] == $vertex2[1]) && ($vertex1[0] != $vertex2[0]) && ($type1 == S_TYPE || $type1 == N_TYPE)) { if (is_verb_selected($sentence,$vertex2[0])) $new_edge = add_reference_word_to_sentence($sentence,$vertex1[0],$vertex2[0],S_TYPE); else if (isset($sentence[$vertex2[0]]['preposition'])) { $new_edge = add_reference_word_to_sentence($sentence,$vertex2[0],$vertex1[0],$type2); copy_preposition($sentence,$vertex2[0],$new_edge); } } } } } } } function check_url($url) { if (substr($url,0,5)=="http:") return $url; else return "http://$url"; } ?>