
    Αi"                        S r SSKrSSKrSSKrSSKrSSKrSSKJ	r	  / r
/ SQrSrSr " S S5      r " S	 S
5      rSqSqSqSqS rS"S jr\	" SSSSS9S 5       r\R.                  " \SS9r\R.                  " \SS9r\	" SSSSS9S 5       rS r\	" SSSSS9S 5       r\	" SSSSS9S 5       rS r\	" SSSSS9S 5       r\	" SSSSS9S 5       r \	" SSSSS9S 5       r!\	" SSSSS9S 5       r"S r#\	" SSSSS9S  5       r$\%S!:X  a  \#" 5         gg)#aD  
Movielens 1-M dataset.

Movielens 1-M dataset contains 1 million ratings from 6000 users on 4000
movies, which was collected by GroupLens Research. This module will download
Movielens 1-M dataset from
http://files.grouplens.org/datasets/movielens/ml-1m.zip and parse training
set and test set into paddle reader creators.

    N)
deprecated)         #   -   2   8   z3https://dataset.bj.bcebos.com/movielens%2Fml-1m.zip c4d9eecfca2ab87c1945afe126590906c                   0    \ rS rSrSrS rS rS rS rSr	g)		MovieInfo+   zE
Movie id, title and categories information are stored in MovieInfo.
c                 <    [        U5      U l        X l        X0l        g N)intindex
categoriestitle)selfr   r   r   s       X/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/dataset/movielens.py__init__MovieInfo.__init__0   s    Z
$
    c                     U R                   U R                   Vs/ s H  n[        U   PM     snU R                  R	                  5        Vs/ s H  n[
        UR                  5          PM     sn/$ s  snf s  snf )z
Get information from a movie.
)r   r   CATEGORIES_DICTr   splitMOVIE_TITLE_DICTlower)r   cws      r   valueMovieInfo.value5   sc    
 JJ)-9A_Q926**2B2B2DE2DQaggi(2DE
 	
9Es   A0!A5c                 V    SU R                    SU R                   SU R                   S3$ )Nz<MovieInfo id(z	), title(z), categories()>)r   r   r   r   s    r   __str__MovieInfo.__str__?   s+    

|9TZZLtN__abbr   c                 "    U R                  5       $ r   )r&   r%   s    r   __repr__MovieInfo.__repr__B   s    ||~r   )r   r   r   N
__name__
__module____qualname____firstlineno____doc__r   r!   r&   r)   __static_attributes__ r   r   r   r   +   s    

cr   r   c                   0    \ rS rSrSrS rS rS rS rSr	g)	UserInfoF   zC
User id, gender, age, and job information are stored in UserInfo.
c                     [        U5      U l        US:H  U l        [        R                  [        U5      5      U l        [        U5      U l        g )NM)r   r   is_male	age_tableagejob_id)r   r   genderr:   r;   s        r   r   UserInfo.__init__K   s7    Z
}??3s8,&kr   c                 p    U R                   U R                  (       a  SOSU R                  U R                  /$ )z
Get information from a user.
r   r   )r   r8   r:   r;   r%   s    r   r!   UserInfo.valueQ   s'     

A1dhhLLr   c           	          U R                   (       a  SOSnSU R                   SU S[        U R                      SU R                   S3	$ )Nr7   Fz<UserInfo id(z
), gender(z), age(z), job(r$   )r8   r   r9   r:   r;   )r   r<   s     r   r&   UserInfo.__str__W   sH    #tzzl*VHGIdhhDWCXX_`d`k`k_llnoor   c                     [        U 5      $ r   )strr%   s    r   r)   UserInfo.__repr__[   s    4yr   )r:   r   r8   r;   Nr+   r2   r   r   r4   r4   F   s    "Mpr   r4   c                  L   [         R                  R                  R                  [        S[
        5      n [        Gc2  [        R                  " S5      n[        R                  " U S9 nUR                  5        GH  n[        U[        R                  5      (       d   e0 q[        5       n[        5       nUR                  S5       n[!        U5       H  u  pxUR#                  SS9nUR%                  5       R'                  S5      u  pnUR'                  S5      nU H  nUR)                  U5        M     UR+                  U
5      R-                  S	5      n
[/        XU
S
9[        [1        U	5      '   U
R'                  5        H"  nUR)                  UR3                  5       5        M$     M     S S S 5        0 q[!        U5       H  u  p}U[4        U'   M     0 q[!        U5       H  u  p|U[6        U'   M     0 qUR                  S5       nU HS  nUR#                  SS9nUR%                  5       R'                  S5      u  nnnnn[;        UUUUS9[8        [1        U5      '   MU     S S S 5        GM     S S S 5        U $ U $ ! , (       d  f       N= f! , (       d  f       GM  = f! , (       d  f       U $ = f)N	movielensz^(.*)\((\d+)\)$filezml-1m/movies.datlatinencoding::|r   )r   r   r   zml-1m/users.dat)r   r<   r:   r;   )paddledatasetcommondownloadURLMD5
MOVIE_INFOrecompilezipfileZipFileinfolist
isinstanceZipInfosetopen	enumeratedecodestripr   addmatchgroupr   r   r   r   r   	USER_INFOr4   )fnpatternpackageinfotitle_word_setcategories_set
movie_fileilinemovie_idr   r   r   r    	user_fileuidr<   r:   job_s                       r   __initialize_meta_info__rt   e   s@   				'	'[#	>B**/0__"%((*!$8888
!$!$\\"45#,Z#8#{{G{<6:jjl6H6H6N3%/%5%5c%:
!+A*..q1 ", 'e 4 : :1 =4="*5
3x=1 "'A*..qwwy9 "/ $9 6 $& %n5DA*+$Q' 6 #%%n5DA)*OA& 6 	\\"34	 )#{{G{<37::<3E3Ed3K0VS#q.6"%f#c/	#c(+ !* 54? + &N I2IC 654 54A &%N Is@   &AJC!I0$AJ=AJJ0
I>:J
J	J
J#Fc              #     #    [        5       n[        R                  R                  U 5        [        R
                  " US9 nUR                  S5       nU H  nUR                  SS9n[        R                  R                  5       U:  U:X  d  M9  UR                  5       R                  S5      u  pxpY[        U5      n[        U5      n[        U5      S-  S-
  n[        U   n
[        U   nUR                  5       U
R                  5       -   U//-   v   M     S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f7f)NrH   zml-1m/ratings.datrJ   rK   rM      g      @)rt   nprandomseedrX   rY   r^   r`   ra   r   r   floatrU   re   r!   )	rand_seed
test_ratiois_testrf   rh   ratingrn   rq   mov_idrs   movusrs               r   
__reader__r      s     	!	#BIINN9R G()VD;;;0D		  "Z/G;)-););D)A&V#hVv*S0 (niikCIIK/F8*<<  	* 	! )) 	! s<   >E D78D&BD&D7	E&
D4	0D77
EEz2.0.0zpaddle.text.datasets.Movielensr   z>Please use new dataset API which supports paddle.io.DataLoader)since	update_tolevelreasonc                     ^  U 4S j$ )Nc                     > [        S0 T D6$ )Nr2   )r   kwargss   r   <lambda>$__reader_creator__.<locals>.<lambda>   s    :''r   r2   r   s   `r   __reader_creator__r      s     ('r   )r}   Tc                  "    [        5         [        $ )z
Get movie title dictionary.
)rt   r   r2   r   r   get_movie_title_dictr      s     r   c                 >    U R                   UR                   :  a  U $ U$ r   )r   abs     r   __max_index_info__r      s    wwr   c                      [        5         [        R                  " [        [	        [
        R                  5       5      5      R                  $ )z$
Get the maximum value of movie id.
)rt   	functoolsreducer   listrU   valuesr   r2   r   r   max_movie_idr      s2     .Z5F5F5H0IJPPPr   c                      [        5         [        R                  " [        [	        [
        R                  5       5      5      R                  $ )z#
Get the maximum value of user id.
)rt   r   r   r   r   re   r   r   r2   r   r   max_user_idr      s2     .Y5E5E5G0HIOOOr   c                 >    U R                   UR                   :  a  U $ U$ r   )r;   r   s     r   __max_job_id_impl__r      s    xx!((r   c                      [        5         [        R                  " [        [	        [
        R                  5       5      5      R                  $ )z"
Get the maximum value of job id.
)rt   r   r   r   r   re   r   r;   r2   r   r   
max_job_idr      s5     T)"2"2"45fr   c                  "    [        5         [        $ )z"
Get movie categories dictionary.
)rt   r   r2   r   r   movie_categoriesr      s     r   c                  "    [        5         [        $ )z
Get user info dictionary.
)rt   re   r2   r   r   	user_infor     s     r   c                  "    [        5         [        $ )z
Get movie info dictionary.
)rt   rU   r2   r   r   
movie_infor     s     r   c                      [        [        5       " 5       5       H  u  pM     [        [        5       " 5       5       H  u  p!M     [        W W5        g r   )r_   traintestprint)train_countrs   
test_counts      r   unittestr   (  s>    #EGI. /"468,
 - 
+z"r   c                  j    [         R                  R                  R                  [        S[
        5        g )NrG   )rO   rP   rQ   rR   rS   rT   r2   r   r   fetchr   1  s      NN""3S9r   __main__)r   g?F)&r0   r   rV   rX   numpyrw   paddle.dataset.commonrO   paddle.utilsr   __all__r9   rS   rT   r   r4   rU   r   r   re   rt   r   r   partialr   r   r   r   r   r   r   r   r   r   r   r   r   r,   r2   r   r   <module>r      s  	  	    #
'	 <( 6 2 
 	,^=( 
.
K	(( 	,e<+T: 
.
K	 
.
K	QQ 
.
K	PP 
.
K	 
.
K	 
.
K	 
.
K	# 
.
K	:: zJ r   