Recommender Systems an Introduction Chapter07 Evaluating Recommender Systems
Integrating a Recommender System Into DSpace
Transcript of Integrating a Recommender System Into DSpace
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 1/14
Integrating a Recommender System into Dspace
Jonathan Blood
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 2/14
Introduction
This paper will take a look at integrating a item based recommender system into DSpace with the
help of Apache Mahout. Apache Mahout is a suite of machine learning libraries designed to be
scalable and robust.[1]
Recommender Systems are software tools which provide suggestions for items that a user may be
interested in.[2] For a breakdown of the different kind of recommender systems take a look at the
Wikipedia page for recommender systems. For DSpace this will require implementing a
collaborative item based recommender system that will rely on users rating DSpace items in order
to generate accurate recommendations.
An example of a recommender system that is used on http://www.amazon.co.uk
In order to implement a recommender system in DSpace there are a number of steps that will need
to be completed:
1.
Create a table in the DSpace database in order to store the users recommendations.
2. Create a way to manipulate this table with basic operations: create, read, update
and delete.
3. Create the recommender system with the help of Mahout.
4. In the user interface of DSpace create a method to add or update a rating on a DSpace
item and provide a list of recommended items on the item display page.
Development
This chapter will focus on integrating the recommender system into the DSpace application. The
implementation will be reviewed in more detail under the four headings:
1. Storage
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 3/14
2. Database Helper Class for the Ratings Table
3. Creating the Recommender System
4. User Interface Changes
For the full implementation of the recommender system into DSpace check out this Github page.
Note: The following will denote the DSpace 5.2 source directory <dspace-src>.
Step 1: Storage
This step will look at creating the database table that will be used to store user ratings for items in
DSpace.
The table will consist of the following columns:
rating_id Primary key so it is possible to uniquely select records.
eperson_id The users unique identifier.
dspace_object_id This will store the unique identifier of the item.
rating A rating between 1-5 (higher the better).
In <dspace-src>/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/ create a file called
V5.2__recommender_system_schema.sql and insert the following:
!! #$%&' $() *'+,'(-' ./ *./0' 0$.1(2 3/0 0'-/44'()'0 *5*.'4
6789#8 :8;<8=68 0$.1(2*>*'+?
6789#8 #9@A8 0$.1(2*
B
0$.1(2>1) C=#8D87 =E# =<AAF
'G'0*/(>1) C=#8D87F
)*G$-'>/%H'-.>1) C=#8D87F
0$.1(2 C=#8D87F
6E=:#79C=# 0$.1(2*>GI'5 J7CK97L M8L B0$.1(2>1)N
N?
By creating this file with this particular naming convention this SQL script will be picked up by
DSpace on initial installation or upgrade to DSpace 5.2 and will automatically import this
database table and sequence into the DSpace database.
Step 2: Database Helper Class for the Ratings Table
In the previous step the database table to store the user ratings was created. This step will look at
creating a helper class which will perform some basic manipulation of this table. This class will
need the following methods:
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 4/14
addRating() Adds a rating record to the table.
hasRating() Checks if a record already exists for given eperson and item.
getRating() Get a users rating on an item.
updateRating() Update an existing ratings value.
deleteObjectRating() This will be called when an item is deleted. This method willdelete all rating records for a given item.
These methods will make use of the DatabaseManager class in DSpace to help manipulate this
table. In <dspace-src>/dspace-api/src/main/java/ create a package called com.jonathanblood.content . In
this package create a class called RatingsManager.java:
OPP
P #Q' -/(.'(.* /3 .Q1* 31&' $0' *,%H'-. ./ .Q' &1-'(*' $() -/G5012Q.
P )'.$1&') 1( .Q' AC68=:8 $() =E#C68 31&'* $. .Q' 0//. /3 .Q' */,0-'
P .0'' $() $R$1&$%&' /(&1(' $.
P
P Q..GSOOTTTU)*G$-'U/02O&1-'(*'O
PO
G$-I$2' -/4UH/($.Q$(%&//)U-/(.'(.?
14G/0. /02U$G$-Q'U&/2VHUA/22'0?
14G/0. /02U)*G$-'U-/0'U6/(.'W.?
14G/0. /02U)*G$-'U*./0$2'U0)%4*UX$.$%$*'K$($2'0?
14G/0. /02U)*G$-'U*./0$2'U0)%4*U#$%&'7/T?
14G/0. /02U)*G$-'U*./0$2'U0)%4*U#$%&'7/TC.'0$./0?
14G/0. H$R$U*+&U:;A8W-'G.1/(?
OPP
P 6&$** 0'G0'*'(.1(2 $( 0$.1(2 1( X:G$-'U
P
P Y$,.Q/0 Z/($.Q$( @&//)
P YR'0*1/( [7'R1*1/([
PO
G,%&1- -&$** 7$.1(2*K$($2'0
\
OPP &/2VH -$.'2/05 PO
G01R$.' *.$.1- 31($& A/22'0 &/2 ] A/22'0U2'.A/22'0B7$.1(2*K$($2'0U-&$**N?
OPP
P <G)$.' 0$.1(2 :;A
PO
G01R$.' :.01(2 ,G)$.'7$.1(2 ] ^<JX9#8 0$.1(2* :8# 0$.1(2 ] _ `a878 'G'0*/(>1) ] _ 9=X
)*G$-'>/%H'-.>1) ] _^?
OPP
P D'. 0$.1(2 :;A
PO
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 5/14
G01R$.' :.01(2 2'.7$.1(2 ] ^:8A86# 0$.1(2 b7EK 0$.1(2* `a878 'G'0*/(>1) ] _ 9=X
)*G$-'>/%H'-.>1) ] _^?
G,%&1- 7$.1(2*K$($2'0BN
\
c
G,%&1- R/1) $))7$.1(2B6/(.'W. -/(.'W.F 1(. 'G'0*/(C)F 1(. )*G$-'E%H'-.C)F 1(. 0$.1(2N
\
.05
\
#$%&'7/T 0/T ] X$.$%$*'K$($2'0U-0'$.'B-/(.'W.F ^0$.1(2*^N?
0/TU*'.6/&,4(B^'G'0*/(>1)^F 'G'0*/(C)N?
0/TU*'.6/&,4(B^)*G$-'>/%H'-.>1)^F )*G$-'E%H'-.C)N?
0/TU*'.6/&,4(B^0$.1(2^F 0$.1(2N?
X$.$%$*'K$($2'0U,G)$.'B-/(.'W.F 0/TN?
c
-$.-Q B:;A8W-'G.1/( 'N
\
&/2U'00/0B^800/0 $))1(2 $ 0$.1(2U^F 'N?
c
c
G,%&1- %//&'$( Q$*7$.1(2B6/(.'W. -/(.'W.F 1(. 'G'0*/(C)F 1(. )*G$-'E%H'-.C)N
\
:.01(2 *+& ] ^:8A86# P b7EK 79#C=D: `a878 8J87:E=>CX ] ^ d 'G'0*/(C) d
^ 9=X X:J968>E@Z86#>CX ] ^ d )*G$-'E%H'-.C)?
.05
\
#$%&'7/TC.'0$./0 1.'0$./0 ] X$.$%$*'K$($2'0U+,'05B-/(.'W.F *+&N?
13 Be1.'0$./0UQ$*='W.BNN
\
0'.,0( 3$&*'?
c
c
-$.-Q B:;A8W-'G.1/( 'N
\
&/2U'00/0B^800/0 -Q'-I1(2 13 /%H'-. Q$* 0$.1(2U^F 'N?
c
0'.,0( .0,'?
c
G,%&1- 1(. 2'.7$.1(2B6/(.'W. -/(.'W.F 1(. 'G'0*/(C)F 1(. )*G$-'E%H'-.C)N
\
E%H'-.fg G$0$4* ] \'G'0*/(C)F )*G$-'E%H'-.C)c?
.05
\
#$%&'7/TC.'0$./0 1.'0$./0 ] X$.$%$*'K$($2'0U+,'05B-/(.'W.F 2'.7$.1(2F G$0$4*N?
13B1.'0$./0UQ$*='W.BNN
\
#$%&'7/T 0/T ] 1.'0$./0U('W.BN?
0'.,0( 0/TU2'.C(.6/&,4(B^0$.1(2^N?
c
c
-$.-Q B:;A8W-'G.1/( 'N
\
&/2U'00/0B^800/0 2'..1(2 0$.1(2U^F 'N?c
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 6/14
0'.,0( !h?
c
G,%&1- R/1) ,G)$.'7$.1(2B6/(.'W. -/(.'W.F 1(. 'G'0*/(C)F 1(. )*G$-'E%H'-.C)F 1(. 0$.1(2N
\
E%H'-.fg G$0$4* ] \ 0$.1(2F 'G'0*/(C)F )*G$-'E%H'-.C)c?.05
\
X$.$%$*'K$($2'0U,G)$.';,'05B-/(.'W.F ,G)$.'7$.1(2F G$0$4*N?
c -$.-Q B:;A8W-'G.1/( 'N
\
&/2U'00/0B^800/0 ,G)$.1(2 0$.1(2U^F 'N?
c
c
G,%&1- R/1) )'&'.'E%H'-.7$.1(2*B6/(.'W. -/(.'W.F 1(. )*G$-'E%H'-.C)N
\
.05
\
X$.$%$*'K$($2'0U)'&'.'@5i$&,'B-/(.'W.F ^0$.1(2*^F ^)*G$-'>/%H'-.>1)^F
)*G$-'E%H'-.C)N?
c -$.-Q B:;A8W-'G.1/( 'N
\
&/2U'00/0B^800/0 )'&'.1(2 $( 1.'4j* 0$.1(2*U^F 'N?
c
c
c
Step 3: Creating the Recommender System
This step will look at creating the recommender system in DSpace with the help of the Mahout
libraries. Before looking at the recommender implementation the DSpace project will require the
external Mahout libraries.
The external Mahout libraries can be included into the DSpace project with the help of Maven. In
<dspace-src>/dspace-api/pom.xml add the following dependencies:
k)'G'()'(-5l
k20/,GC)l/02U$G$-Q'U4$Q/,.kO20/,GC)l
k$0.13$-.C)l4$Q/,.!1(.'20$.1/(kO$0.13$-.C)l
kR'0*1/(lmUhmUhkOR'0*1/(l kO)'G'()'(-5l
k)'G'()'(-5l
k20/,GC)l/02U$G$-Q'U4$Q/,.kO20/,GC)l
k$0.13$-.C)l4$Q/,.!40kO$0.13$-.C)l
kR'0*1/(lmUhmUhkOR'0*1/(l
kO)'G'()'(-5l
When Dspace is built and compiled this will download the Mahout libraries that are needed. Now
that the external libraries are sorted it’s possible to implement the recommender class and break
down how this implementation works. The class will consist of a single method called
getRecommendations() that will take in a item id and a number of recommended items as a
parameter. The method will return a list of recommendations that were calculated.
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 7/14
In <dspace-src>/dspace-api/src/main/java/ create a package called com.jonathanblood.recommender . In
this package create a class called Recommender.java:
G$-I$2' -/4UH/($.Q$(%&//)U0'-/44'()'0?
14G/0. /02U$G$-Q'U&/2VHUA/22'0?
14G/0. /02U$G$-Q'U4$Q/,.U-3U.$*.'U-/44/(U#$*.'8W-'G.1/(?
14G/0. /02U$G$-Q'U4$Q/,.U-3U.$*.'U14G&U4/)'&UH)%-UJ/*.20':;AZX@6X$.$K/)'&?
14G/0. /02U$G$-Q'U4$Q/,.U-3U.$*.'U14G&U*141&$01.5UA/2A1I'&1Q//):141&$01.5?
14G/0. /02U$G$-Q'U4$Q/,.U-3U.$*.'U4/)'&UX$.$K/)'&?
14G/0. /02U$G$-Q'U4$Q/,.U-3U.$*.'U14G&U0'-/44'()'0UD'('01-C.'4@$*')7'-/44'()'0?
14G/0. /02U)*G$-'U*./0$2'U0)%4*UX$.$%$*'K$($2'0?
14G/0. H$R$WU*+&UX$.$:/,0-'?
14G/0. H$R$U,.1&UA1*.?
OPP
P 60'$.') %5 Z/( /( mnOmoOhnU
PO
G,%&1- -&$** 7'-/44'()'0
\
OPP &/2VH -$.'2/05 PO
G01R$.' *.$.1- 31($& A/22'0 &/2 ] A/22'0U2'.A/22'0B7'-/44'()'0U-&$**N?
G,%&1- A1*. 2'.7'-/44'()$.1/(*B1(. 1.'4C)F 1(. (,4%'0E37'-*N
\
X$.$:/,0-' )$.$:/,0-' ] X$.$%$*'K$($2'0U2'.X$.$:/,0-'BN?
X$.$K/)'& 4/)'& ] ('T J/*.20':;AZX@6X$.$K/)'&B)$.$:/,0-'F ^0$.1(2*^F
^'G'0*/(>1)^F ^)*G$-'>/%H'-.>1)^F ^0$.1(2^F (,&&N?
A/2A1I'&1Q//):141&$01.5 *141&$01.5 ] (,&&?
.05
\
*141&$01.5 ] ('T A/2A1I'&1Q//):141&$01.5B4/)'&N?
D'('01-C.'4@$*')7'-/44'()'0 0'-/44'()'0 ] ('T D'('01-C.'4@$*')7'-/44'()'0B4/)'&F
*141&$01.5N?
A1*. 0'-/44'()$.1/(* ] 0'-/44'()'0U4/*.:141&$0C.'4*B1.'4C)F (,4%'0E37'-*N?
0'.,0( 0'-/44'()$.1/(*?
c -$.-Q B#$*.'8W-'G.1/( 'N
\
&/2U'00/0B^6/,&) (/. -$&-,&$.' 0'-/44'()$.1/(*^F 'N?
c
0'.,0( (,&&?
c
c
It’s time to breakdown the logic of the getRecommendations() method:X$.$:/,0-' )$.$:/,0-' ] X$.$%$*'K$($2'0U2'.X$.$:/,0-'BN?
X$.$K/)'& 4/)'& ] ('T J/*.20':;AZX@6X$.$K/)'&B)$.$:/,0-'F ^0$.1(2*^F
^'G'0*/(>1)^F ^)*G$-'>/%H'-.>1)^F ^0$.1(2^F (,&&N?
In this code snippet a connection to the database is obtained using the DatabaseManager class in
DSpace. After this a data model for PostgeSQL is instanciated that will allow for the ability
to load data from the ratings table found in the DSpace database.
Note: In this paper the assumption here is that PostgreSQL is used for the database in DSpace.
Mahout also supports other ways of loading data into the data model such as from a MySQL
database or from a file.
A/2A1I'&1Q//):141&$01.5 *141&$01.5 ] ('T A/2A1I'&1Q//):141&$01.5B4/)'&N?
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 8/14
D'('01-C.'4@$*')7'-/44'()'0 0'-/44'()'0 ] ('T D'('01-C.'4@$*')7'-/44'()'0B4/)'&F *141&$01.5N?
In the following code snippet the LogLikelihoodSimilarity is used in order to calculate the
recommended items for the recommender system.
The Tanimote coefficient is the ratio count of the number of items two users have in common
divided by the number of items both users have a preference for. The problem with this approach
is that in a large data set there is a good chance that two users will have overlapping similarities in
items. The LogLikelihoodSimilarity helps to alleviate this problem by also taking into account the
overlap of two users items that happens by chance.[3]
Mahout comes with a number of different similarity methods that can be used instead
of LogLikelihoodSimilarity such as:
•
PearsonCorrelationSimilarity
• TanimoteCoefficientSimilarity
• SpearmanCorrelationSimilarity
In the next line of code the recommender system takes in the datamodel (data) and the similarity
calculation ( LogLikelihoodSimilarity).
A1*. 0'-/44'()$.1/(* ] 0'-/44'()'0U4/*.:141&$0C.'4*B1.'4C)F (,4%'0E37'-*N?
0'.,0( 0'-/44'()$.1/(*?
The purpose of this code snippet is to produce recommendations by passing in the item id and the
number of recommendations that should be returned. This is calculated by using the data from the
model and the similarity calculation that was passed into the GenericItemBasedRecommender .
Step 4: User Interface Changes
In the previous step the recommender class was created which can generate a list of recommended
items in DSpace. The following needs to be done now:
• Add a way for users to add and update ratings for an item.
•
On the item display page list item recommendations that are returned by the
recommender system.
In DSpace there are two User Interfaces JSPUI and XMLUI. For this paper it will only
be implemented for the XMLUI interface. On the DSpace item display page will be an option for
the user to add/update a rating for an item and also list a number of recommended items. These
elements will be implemented below. In <dspace-src>/dspace-
xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/ItemViewer.java modify theaddBody() method as
following:
8J'0*/( -,00'(.<*'0 ] -/(.'W.U2'.6,00'(.<*'0BN?
13 B1.'4U1*90-Q1R')BN pp -,00'(.<*'0 e] (,&&N \
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 9/14
7$.1(2*K$($2'0 0$.1(2*K$($2'0 ] ('T 7$.1(2*K$($2'0BN?
1(. 0$.1(2 ] 0$.1(2*K$($2'0U2'.7$.1(2B-/(.'W.F -,00'(.<*'0U2'.CXBNF 1.'4U2'.CXBNN?
X1R1*1/( 0$.1(2X1R ] )1R1*1/(U$))C(.'0$-.1R'X1R1*1/(B^$))!0$.1(2^F -/(.'W.J$.Qd^O$))!
0$.1(2^F X1R1*1/(UK8#aEX>JE:#F ^$))!0$.1(2^N?
/02U)*G$-'U$GGUW4&,1UT1(2U'&'4'(.UA1*. 3/04 ] 0$.1(2X1RU$))A1*.B^*,%41.!0$.1(2^F
/02U)*G$-'U$GGUW4&,1UT1(2U'&'4'(.UA1*.U#LJ8>bE7KN?
3/04U*'.a'$)B4'**$2'B^W4&,1U90.13$-.@0/T*'0UC.'4i1'T'0U$))0$.1(2^ NN?
OO J&$1( /&) *'&'-. &1*.U
:'&'-. *'&'-. ] 3/04U$))C.'4BNU$)):'&'-.B^0$.1(2^F^*,%41.!*'&'-.^N?
*'&'-.U*'.7'+,10')BN?
3/0 B1(. 1 ] h? 1 k] n? 1ddN \
*'&'-.U$))EG.1/(B1F C(.'2'0U./:.01(2B1NN?
c
13 B0$.1(2 e] !hN \
*'&'-.U*'.EG.1/(:'&'-.')B0$.1(2N?
c
3/04U$))C.'4BNU$))a1))'(B^,*'01)^NU*'.i$&,'B-,00'(.<*'0U2'.CXBNN?
3/04U$))C.'4BNU$))a1))'(B^1.'41)^NU*'.i$&,'B1.'4U2'.CXBNN?
3/04U$))C.'4BNU$))@,../(B^*,%41.^NU*'.i$&,'B^:,%41.^N?
OOJ01(. /,. 0'-/44'()$.1/(*
X1R1*1/( 0'-X1R ] )1R1*1/(U$))X1R1*1/(B^0'-/44'()$.1/(*^N?
0'-X1RU*'.a'$)B4'**$2'B^W4&,1U90.13$-.@0/T*'0UC.'4i1'T'0U0'-/44'()$.1/(*^ NN?
/02U)*G$-'U$GGUW4&,1UT1(2U'&'4'(.UA1*. 0'-A1*. ] 0'-X1RU$))A1*.B^0'-/44'()$.1/(*!
&1*.^N?
7'-/44'()'0 0'-/44'()'0 ] ('T 7'-/44'()'0BN?
A1*.k7'-/44'()')C.'4l 0'-/44'()$.1/(* ] 0'-/44'()'0U2'.7'-/44'()$.1/(*B1.'4U2'.CXBNF
qN?
13 B0'-/44'()$.1/(* e] (,&&N \
3/0 B7'-/44'()')C.'4 0'-/44'()$.1/( S 0'-/44'()$.1/(*N \
C.'4 0'-/44'()')C.'4 ] C.'4U31()B-/(.'W.F B1(.N
0'-/44'()$.1/(U2'.C.'4CXBNN?
:.01(2 1.'4<0& ] -/(.'W.J$.Q d ^OQ$()&'O^ d 0'-/44'()')C.'4U2'.a$()&'BN?
0'-A1*.U$))C.'4BNU$))r0'3B1.'4<0&F 0'-/44'()')C.'4U2'.=$4'BNN?
c
c
c
This snippet of code does two things:
1. Creates a form for setting or updating a rating for an item. The form is quite simple and
consists of a dropdown list with rating values from 1-5, hidden fields for passing the user
id and item id of an item and a submit button. The form is submitted to a add-rating
action that will handle the form processing for the rating.
2. Below the add ratings form a list of recommended items are shown.
Note: Ideally there would be some kind of skin to the dropdown list (i.e. display 5 stars) or instead
of showing just the title of the recommended items it would also show the items thumbnail if it
was available just so it is more visually appealing to the user.
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 10/14
Ratings form and recommendation list
Since the item display page is modified to include an item rating this will require a change to how
caching works on this page. To see how caching is currently implemented on the item display page this can be seen by taking a look at how the getKey() method in ItemViewer.java:
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 11/14
0'.,0( a$*Q<.1&UQ$*QB)*/U2'.a$()&'BN d ^3,&&S^ d *Q/Tb,&&C.'4B/%H'-.K/)'&NN?
Based on the cache key above it can be seen that a item’s cache will be invalidated when an items
metadata is changed (as showFullItem(objectModel) will change). Since a rating is something that
can change and is not static this will require extending the caching key to include an eperson id
and a rating. That is assuming the user has provided a rating to the item in question. This change
will result in the caching key becoming invalidated when a items rating is added or updated. This
is achieved by modifying the addKey() method as following:
:.01(2@,1&)'0 *% ] ('T :.01(2@,1&)'0BN?
*%U$GG'()B)*/U2'.a$()&'BNN?
*%U$GG'()B^3,&&S^N?
*%U$GG'()B*Q/Tb,&&C.'4B/%H'-.K/)'&NN?
8J'0*/( -,00'(.<*'0 ] -/(.'W.U2'.6,00'(.<*'0BN?
13 B-,00'(.<*'0 e] (,&&N
\
7$.1(2*K$($2'0 0$.1(2*K$($2'0 ] ('T 7$.1(2*K$($2'0BN?1(. 0$.1(2 ] 0$.1(2*K$($2'0U2'.7$.1(2B-/(.'W.F -,00'(.<*'0U2'.CXBNF )*/U2'.CXBNN?
*%U$GG'()B^>^N?
*%U$GG'()B-,00'(.<*'0U2'.CXBNN?
*%U$GG'()B^>^N?
*%U$GG'()B0$.1(2N?
c
0'.,0( a$*Q<.1&UQ$*QB*%U./:.01(2BNN?
OO0'.,0( a$*Q<.1&UQ$*QB)*/U2'.a$()&'BN d ^3,&&S^ d *Q/Tb,&&C.'4B/%H'-.K/)'&NN
In the ItemViewer.java changes there are two new internationalization strings that are introduced.
In <dspace-src>/dspace-xmlui/src/main/webapp/i18n/messages.xml add the following strings:k4'**$2' I'5]^W4&,1U90.13$-.@0/T*'0UC.'4i1'T'0U$))0$.1(2^ l9)) 7$.1(2kO4'**$2'l
k4'**$2' I'5]^W4&,1U90.13$-.@0/T*'0UC.'4i1'T'0U0'-/44'()$.1/(*^ l7'-/44'()$.1/(*kO4'**$2'l
The next task to implement is the form processing for adding a rating. This will require adding a
mapping pattern for the add-ratings page that will call
a AddRatingsAction class. This AddRatingsAction class will add/update a sd to the database and
redirects the user back to the item display page. In <dspace-src>/dspace-
xmlui/src/main/resources/aspects/ViewArtifacts/sitemap.xmap add the following action to map:actions: k4$GS$-.1/( ($4']^9))7$.1(2*9-.1/(^
*0-]^/02U)*G$-'U$GGUW4&,1U$*G'-.UR1'T90.13$-.*U9))7$.1(2*9-.1/(^ Ol
In map:pipeline add the following pattern match:
k4$GS*'&'-. .5G']^9,.Q'(.1-$.'):'&'-./0^l
k4$GSTQ'( .'*.]^'G'0*/(^l
k4$GS4$.-Q G$..'0(]^$))!0$.1(2^l
k4$GS$-. .5G']^9))7$.1(2*9-.1/(^l
k4$GSG$0$4'.'0 ($4']^,*'01)^ R$&,']^\,*'01)c^Ol
k4$GSG$0$4'.'0 ($4']^1.'41)^ R$&,']^\1.'41)c^Ol
k4$GSG$0$4'.'0 ($4']^0$.1(2^ R$&,']^\0$.1(2c^Ol
kO4$GS$-.l
kO4$GS4$.-Ql
kO4$GSTQ'(l
kO4$GS*'&'-.l
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 12/14
The AddRatingsAction class will do the following:
• Create/update rating for an item from the add-rating form.
• Redirect user back to the item display page.
In <dspace-src>/ dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/viewArtifacts/ add a Java class
called AddRatingsAction.java :
OPP
P #Q' -/(.'(.* /3 .Q1* 31&' $0' *,%H'-. ./ .Q' &1-'(*' $() -/G5012Q.
P )'.$1&') 1( .Q' AC68=:8 $() =E#C68 31&'* $. .Q' 0//. /3 .Q' */,0-'
P .0'' $() $R$1&$%&' /(&1(' $.
P
P Q..GSOOTTTU)*G$-'U/02O&1-'(*'O
PO
G$-I$2' /02U)*G$-'U$GGUW4&,1U$*G'-.UR1'T90.13$-.*?
14G/0. H$R$WU*'0R&'.UQ..GUa..G:'0R&'.7'*G/(*'?
14G/0. -/4UH/($.Q$(%&//)U-/(.'(.U7$.1(2*K$($2'0?
14G/0. /02U)*G$-'U$GGUW4&,1U,.1&*U6/(.'W.<.1&?
14G/0. /02U)*G$-'U$GGUW4&,1U,.1&*Ua$()&'<.1&?
14G/0. /02U)*G$-'U-/0'U6/(.'W.?
14G/0. /02U)*G$-'U-/0'U6/(312,0$.1/(K$($2'0?
14G/0. /02U)*G$-'U,*$2'U<*$2'8R'(.?
14G/0. /02U)*G$-'U,.1&*UX:G$-'?
14G/0. /02U)*G$-'U-/(.'(.UX:G$-'E%H'-.?
14G/0. /02U)*G$-'U-/(.'(.U@1.*.0'$4?
14G/0. /02U)*G$-'U-/(.'(.UC.'4?
14G/0. /02U)*G$-'U-/(.'(.U@,()&'?
14G/0. /02U)*G$-'UQ$()&'Ua$()&'K$($2'0?
14G/0. /02U$G$-Q'U&/2VHUA/22'0?
14G/0. /02U$G$-Q'U-/-//(U'(R10/(4'(.UQ..GUa..G8(R10/(4'(.?
14G/0. /02U$G$-Q'U-/-//(U'(R10/(4'(.U7'+,'*.?
14G/0. /02U$G$-Q'U-/-//(U'(R10/(4'(.UE%H'-.K/)'&a'&G'0?
14G/0. /02U$G$-Q'U-/-//(U'(R10/(4'(.U7')10'-./0?
14G/0. /02U$G$-Q'U-/-//(U'(R10/(4'(.U:/,0-'7'*/&R'0?
14G/0. /02U$G$-Q'U-/-//(U$-.1(2U9%*.0$-.9-.1/(?
14G/0. /02U$G$-Q'U$R$&/(U30$4'T/0IUG$0$4'.'0*UJ$0$4'.'0*?
14G/0. H$R$U*+&U:;A8W-'G.1/(?
14G/0. H$R$U,.1&UK$G?
14G/0. H$R$WU*'0R&'.UQ..GUa..G:'0R&'.7'+,'*.?
OPP
P Y$,.Q/0 Z/($.Q$( @&//)
PO
G,%&1- -&$** 9))7$.1(2*9-.1/( 'W.'()* 9%*.0$-.9-.1/(
\
OPP &/2VH -$.'2/05 PO
G01R$.' *.$.1- 31($& A/22'0 &/2 ] A/22'0U2'.A/22'0B9))7$.1(2*9-.1/(U-&$**N?
G,%&1- K$G $-.B7')10'-./0 0')10'-./0F :/,0-'7'*/&R'0 */,0-'7'*/&R'0F K$G /%H'-.K/)'&F
:.01(2 *.01(2F J$0$4'.'0* G$0$4'.'0*N .Q0/T* 8W-'G.1/(
\
.05
\
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 13/14
31($& a..G:'0R&'.7'*G/(*' Q..G7'*G/(*' ] Ba..G:'0R&'.7'*G/(*'N
/%H'-.K/)'&U2'.Ba..G8(R10/(4'(.Ua##J>78:JE=:8>E@Z86#N?
7'+,'*. 0'+,'*. ] E%H'-.K/)'&a'&G'0U2'.7'+,'*.B/%H'-.K/)'&N?
6/(.'W. -/(.'W. ] 6/(.'W.<.1&U/%.$1(6/(.'W.B/%H'-.K/)'&N?
1(. 1.'4CX ] C(.'2'0UG$0*'C(.B0'+,'*.U2'.J$0$4'.'0B^1.'41)^NN?
1(. ,*'0CX ] C(.'2'0UG$0*'C(.B0'+,'*.U2'.J$0$4'.'0B^,*'01)^NN?1(. 0$.1(2 ] C(.'2'0UG$0*'C(.B0'+,'*.U2'.J$0$4'.'0B^0$.1(2^NN?
C.'4 1.'4 ] C.'4U31()B-/(.'W.F 1.'4CXN?
7$.1(2*K$($2'0 0$.1(2K$($2'0 ] ('T 7$.1(2*K$($2'0BN?
%//&'$( Q$*7$.1(2 ] 0$.1(2K$($2'0UQ$*7$.1(2B-/(.'W.F ,*'0CXF 1.'4CXN?
13 BQ$*7$.1(2N
\
0$.1(2K$($2'0U,G)$.'7$.1(2B-/(.'W.F ,*'0CXF 1.'4CXF 0$.1(2N?
c
'&*'
\
0$.1(2K$($2'0U$))7$.1(2B-/(.'W.F ,*'0CXF 1.'4CXF 0$.1(2N?
c
Q..G7'*G/(*'U*'()7')10'-.BQ..G7'*G/(*'U'(-/)'7')10'-.<7AB0'+,'*.U2'.6/(.'W.J$.QBN
d
^OQ$()&'O^ d 1.'4U2'.a$()&'BNNN?
c
-$.-Q B8W-'G.1/( 'N
\
&/2U'00/0B^9)) 0$.1(2 $-.1/( 3$1&')^F 'N?
c
0'.,0( (,&&?
c
c
Conclusion
Following the implementation of the four steps as outlined a simple recommender system is now
integrated into the DSpace application using Mahout. However, there is significant potential for
the addition of other features and functions to build on this simple implementation described here.
See the list below for suggested extensions:
• Extend recommender system to support recommendations for Communities and
Collections in DSpace.
• Make the user interface look better (Some form of ratings slider and improved
recommended items list).
• Add support for dierent Similarities.
• Add support for JSPUI.
• Add support for other databases (only implemented datamodel for PostgreSQL).
• Look at solutions for the cold start problem.
8/17/2019 Integrating a Recommender System Into DSpace
http://slidepdf.com/reader/full/integrating-a-recommender-system-into-dspace 14/14
• Use the ratings table that was created to generate other lists of information. for example:
highest rated item, etc.
References
1. http://mahout.apache.org/general/faq.html
2. http://www.inf.unibz.it/~ricci/papers/intro-rec-sys-handbook.pdf
3. https://www.packtpub.com/big-data-and-business-intelligence/learning-apache-mahout