$candidate_vector_length = $this->prominent_words_helper->compute_vector_length( $candidate_data ); return $this->normalize_score( $raw_score, $candidate_vector_length, $request_vector_length ); } /** * In the prominent words repository, find a $batch_size of all ProminentWord-IndexableID pairs where * prominent words match the set of stems we are interested in. * Request prominent words for indexables in the batch (including the iDF of all words) to calculate * their vector length later. * * @param array $stems The stems in the request. * @param int $batch_size How many indexables to request in one query. * @param int $page The start of the current batch (in pages). * @param int[] $excluded_ids The indexable IDs to exclude. * @param array $post_type The post types that will be searched. * @param bool $only_include_public If only public indexables are included. * * @return array An array of ProminentWords objects, containing their stem, weight, indexable id, * and document frequency. */ protected function get_candidate_words( $stems, $batch_size, $page, $excluded_ids = [], $post_type = [], $only_include_public = false ) { return $this->prominent_words_repository->find_by_list_of_ids( $this->prominent_words_repository->find_ids_by_stems( $stems, $batch_size, $page, $excluded_ids, $post_type, $only_include_public ) ); } /** * For each candidate indexable, computes their matching score related to the request set of prominent words. * The candidate indexables are analyzed in batches. * After having computed scores for a batch the function saves the best candidates until now. * * @param array $request_words The words to match, as an array mapping words to weights. * @param int $limit The max number of suggestions that should be returned by the function. * @param int $batch_size The number of indexables that should be analyzed in every batch. * @param int|null $current_indexable_id The id for the current indexable. * @param bool $include_existing_links Optional. Whether or not to include existing links, defaults to true. * @param array $post_type Optional. The list of post types where suggestions may come from. * @param bool $only_include_public Optional. Only include public indexables, defaults to false. * * @return array An array mapping indexable IDs to scores. Higher scores mean better matches. */ protected function retrieve_suggested_indexable_ids( $request_words, $limit, $batch_size, $current_indexable_id, $include_existing_links = true, $post_type = [], $only_include_public = false ) { // Combine stems, weights and DFs from request. $request_data = $this->compose_request_data( $request_words ); // Calculate vector length of the request set (needed for score normalization later). $request_vector_length = $this->prominent_words_helper->compute_vector_length( $request_data ); // Get all links the post already links to, those shouldn't be suggested. $excluded_indexable_ids = [ $current_indexable_id ]; if ( ! $include_existing_links && $current_indexable_id ) { $links = $this->links_repository->query() ->distinct() ->select( 'indexable_id' ) ->where( 'target_indexable_id', $current_indexable_id ) ->find_many(); $excluded_indexable_ids = \array_merge( $excluded_indexable_ids, \wp_list_pluck( $links, 'indexable_id' ) ); } $excluded_indexable_ids = \array_filter( $excluded_indexable_ids ); $request_stems = \array_keys( $request_data ); $scores = []; $page = 1; do { // Retrieve the words of all indexables in this batch that share prominent word stems with request. $candidates_words = $this->get_candidate_words( $request_stems, $batch_size, $page, $excluded_indexable_ids, $post_type, $only_include_public ); // Transform the prominent words table so that it is indexed by indexable_ids. $candidates_words_by_indexable_ids = $this->group_words_by_indexable_id( $candidates_words ); $batch_scores_size = 0; foreach ( $candidates_words_by_indexable_ids as $id => $candidate_data ) { $scores[ $id ] = $this->calculate_score_for_indexable( $request_data, $request_vector_length, $candidate_data ); ++$batch_scores_size; } // Sort the list of scores and keep only the top $limit of the scores. $scores = $this->get_top_suggestions( $scores, $limit ); ++$page; } while ( $batch_scores_size === $batch_size ); return $scores; } /** * Normalizes the raw score based on the length of the prominent word vectors. * * @param float $raw_score The raw (non-normalized) score. * @param float $vector_length_candidate The vector lengths of the candidate indexable. * @param float $vector_length_request The vector length of the words from the request. * * @return int|float The score, normalized on vector lengths. */ protected function normalize_score( $raw_score, $vector_length_candidate, $vector_length_request ) { $normalizing_factor = ( $vector_length_request * $vector_length_candidate ); if ( $normalizing_factor === 0.0 ) { // We can't divide by 0, so set the score to 0 instead. return 0; } return ( $raw_score / $normalizing_factor ); } /** * Sorts the indexable ids based on the score and returns the top N indexable ids based on a specified limit. * (Returns all indexable ids if there are less indexable ids than specified by the limit.) * * @param array $scores The array matching indexable ids to their scores. * @param int $limit The maximum number of indexables that should be returned. * * @return array The top N indexable ids, sorted from highest to lowest score. */ protected function get_top_suggestions( $scores, $limit ) { // Sort the indexables by descending score. \uasort( $scores, static function ( $score_1, $score_2 ) { if ( $score_1 === $score_2 ) { return 0; } return ( ( $score_1 < $score_2 ) ? 1 : -1 ); } ); // Take the top $limit suggestions, while preserving their ids specified in the keys of the array elements. return \array_slice( $scores, 0, $limit, true ); } /** * Gets the singular label of the given combination of object type and sub type. * * @param string $object_type An object type. For example 'post' or 'term'. * @param string $object_sub_type An object sub type. For example 'page' or 'category'. * * @return string The singular label of the given combination of object type and sub type, * or the empty string if the singular label does not exist. */ protected function get_sub_type_singular_label( $object_type, $object_sub_type ) { switch ( $object_type ) { case 'post': $post_type = \get_post_type_object( $object_sub_type ); if ( $post_type ) { return $post_type->labels->singular_name; } break; case 'term': $taxonomy = \get_taxonomy( $object_sub_type ); if ( $taxonomy ) { return $taxonomy->labels->singular_name; } break; } return ''; } /** * Creates link suggestion data based on the indexables that should be suggested and the scores for these * indexables. * * @param Indexable[] $indexables The indexables for which to create linking suggestions. * @param array $scores The scores for the linking suggestions. * * @return array The internal linking suggestions. */ protected function create_suggestions( $indexables, $scores ) { $objects = $this->retrieve_object_titles( $indexables ); $link_suggestions = []; foreach ( $indexables as $indexable ) { if ( ! \array_key_exists( $indexable->object_type, $objects ) ) { continue; } // Object tied to this indexable. E.g. post, page, term. if ( ! \array_key_exists( $indexable->object_id, $objects[ $indexable->object_type ] ) ) { continue; } $link_suggestions[] = [ 'object_type' => $indexable->object_type, 'id' => (int) ( $indexable->object_id ), 'title' => $objects[ $indexable->object_type ][ $indexable->object_id ]['title'], 'link' => $indexable->permalink, 'isCornerstone' => (bool) $indexable->is_cornerstone, 'labels' => $this->get_labels( $indexable ), 'score' => \round( (float) ( $scores[ $indexable->id ] ), 2 ), ]; } /* * Because the request to the indexables table messes up with the ordering of the suggestions, * we have to sort again. */ $this->sort_suggestions_by_field( $link_suggestions, 'score' ); $cornerstone_suggestions = $this->filter_suggestions( $link_suggestions, true ); $non_cornerstone_suggestions = $this->filter_suggestions( $link_suggestions, false ); return \array_merge_recursive( [], $cornerstone_suggestions, $non_cornerstone_suggestions ); } /** * Retrieves the labels for the link suggestion. * * @param Indexable $indexable The indexable to determine the labels for. * * @return array The labels. */ protected function get_labels( Indexable $indexable ) { $labels = []; if ( $indexable->is_cornerstone ) { $labels[] = 'cornerstone'; } $labels[] = $this->get_sub_type_singular_label( $indexable->object_type, $indexable->object_sub_type ); return $labels; } /** * Sorts the given link suggestion by field. * * @param array $link_suggestions The link suggestions to sort. * @param string $field The field to sort suggestions by. * * @return void */ protected function sort_suggestions_by_field( array &$link_suggestions, $field ) { \usort( $link_suggestions, static function ( $suggestion_1, $suggestion_2 ) use ( $field ) { if ( $suggestion_1[ $field ] === $suggestion_2[ $field ] ) { return 0; } return ( ( $suggestion_1[ $field ] < $suggestion_2[ $field ] ) ? 1 : -1 ); } ); } /** * Filters the suggestions by cornerstone status. * * @param array $link_suggestions The suggestions to filter. * @param bool $cornerstone Whether or not to include the cornerstone suggestions. * * @return array The filtered suggestions. */ protected function filter_suggestions( $link_suggestions, $cornerstone ) { return \array_filter( $link_suggestions, static function ( $suggestion ) use ( $cornerstone ) { return (bool) $suggestion['isCornerstone'] === $cornerstone; } ); } } نرخ قیمت ارز امروز 2023/02/17 جمعه - قیمت طلا

نرخ قیمت ارز امروز 2023/02/17 جمعه

نرخ قیمت ارز امروز 2023/02/17 جمعه ساعت 13:32:33 روز ۱۴۰۱/۱۱/۲۸ بیست و هشت بهمن هزار و چهارصد و یک به شرح جدول زیر مورد داد و ستد واقع شد.

نرخ قیمت زنده ارز

451,929 دلار 510,819 یورو
451,300 بالاترین قیمت دلار 450,100 پایینترین قیمت دلار
0 بالاترین قیمت یورو 0 پایینترین قیمت یورو
574,399 پوند 130,579 درهم
0 بالاترین قیمت پوند 0 پایینترین قیمت پوند
0 بالاترین قیمت درهم 0 پایینترین قیمت درهم
26,109 لیر 70,309 یوان
0 بالاترین قیمت لیر 0 پایینترین قیمت لیر
0 بالاترین قیمت یوان 0 پایینترین قیمت یوان
356,739 ین    
0 بالاترین قیمت ین 0 پایینترین قیمت ین
Rate this post