Extracting context data from user reviews for recommendation: A Linked Data approach Pedro G. Campos Nicolás Rodríguez-Artigot Iván Cantador Departamento de Sistemas de Información Departamento de Ingeniería Informática Departamento de Ingeniería Informática Universidad del Bío-Bío Universidad Autónoma de Madrid Universidad Autónoma de Madrid 4081112 Concepción, Chile 28049 Madrid, Spain 28049 Madrid, Spain pgcampos@ubiobio.cl nic.rodriguez@estudiante.uam.es ivan.cantador@uam.es ABSTRACT An alternative technique is to identify and extract contextual In this paper we describe a novel approach to extract contextual information from freely given user generated contents, such as information from user reviews, which can be exploited by product reviews in e-commerce sites, opinion articles in web context-aware recommender systems. The approach makes use of blogs, and personal posts in online social networks. Among these a generic, large-scale context taxonomy that is composed of types of user generated contents, text reviews have been the most semantic entities from DBpedia, the core ontology and knowledge investigated for recommendation purposes [5][12][14]. base of the Linked Data initiative. The taxonomy is built in a In general, previous work on CARS has been restricted to a semi-automatic fashion through a software tool which, on the one limited number of predefined, static context dimensions and hand, automatically explores DBpedia by online querying for values, assuming that context is fully observable [1]. In this paper, related entities and, on the other hand, allows for manual in contrast, we present a novel approach to extract contextual adjustments of the taxonomy. The proposed approach performs a information from user reviews, under the premise that the context mapping between words in the reviews and elements of the dimensions and values are many and unknown a priori, and may taxonomy. In this case, our tool also allows for the manual change over time, implying that context is partially observable. validation and correction of extracted context annotations. We Our approach makes use of a generic, large-scale context describe the taxonomy creation process and the developed tool, taxonomy that is composed of semantic entities –i.e., and further present some preliminary results regarding the classes/categories and individuals/instances– from DBpedia [15], effectiveness of our approach. the Wikipedia ontology and core knowledge base of the Linked Data1 initiative. The taxonomy is built in a semi-automatic fashion Keywords through a software tool which, on the one hand, automatically Context modeling; Context-aware recommendation; User reviews; explores DBpedia by online querying for related entities and, on Information extraction; Linked Data; DBpedia the other hand, allows for manual adjustments of the taxonomy (Section 2). 1. INTRODUCTION By means of natural language processing techniques and In addition to the users’ preferences –i.e., tastes and interests–, resources, the proposed approach performs a mapping between Context-Aware Recommender Systems (CARS) exploit words in the reviews and the categories and instances in the information about the circumstances under which the users (prefer taxonomy (Section 3). In this case, our tool also allows for the to) interact with items, such as the time of the day, the day of the manual validation and correction of extracted context annotations. week, the weather conditions, and the users’ location, mood, and We present some preliminary results regarding the effectiveness social companion. Studies have shown that contextual conditions of our approach on a well-known dataset of Amazon reviews for may have an important, positive effect on the usefulness of products in three domains, namely books, movies and music recommended items [20] and, in fact, providers have reported a (Section 4). consistent performance improvement when context information is taken into account [2]. 2. CONTEXT TAXONOMY Despite these benefits, CARS are not used extensively. This is To identify context information in user reviews through the mainly due to the lack of available context data associated with proposed approach, we first need a definition of context user preferences, and the difficulty and cost to obtain it. dimensions (a.k.a. context categories or context variables) and The simplest method to acquire context data in a recommender their respective values. As noted in [1], the context dimensions system consists of asking the user to explicitly state the contextual usually have a hierarchical structure, and thus can be modeled by conditions as she interacts with the system items [6]. In general, means of a taxonomy. This is, in fact, the most common context however, users are not willing to provide such information representation followed in the literature [2]. because of a desire for unobtrusiveness, concerns on privacy Different to existing approaches, where small and domain- issues, or simply the time and effort required to provide their dependent context are used, in this paper we advocate for the use feedback. Avoiding asking the user, another way to obtain context of a generic (i.e., domain-independent), large-scale and adjustable data is by means of physical sensors, which e.g. provide periodic context taxonomy. By counting with such taxonomy, it would be records of timestamps, location coordinates, and temperature possible to extract and exploit context information in different measures. Nowadays, these sensors are very common in mobile domains, not being limited to recommendation purposes. devices, but the data they generate have to be continuously processed and transformed into context representations appropriate for CARS. ComplexRec 2017, Como, Italy. 1 Linked Data, http://linkeddata.org 2017. Copyright for the individual papers remains with the authors. Copying permitted for private and academic purposes. This volume is published and copyrighted by its editors. Published on CEUR-WS, Volume 1892. Figure 1. Screenshots of the Context Taxonomy Editor (left) and the Context Annotation Validator (right) of the developed tool. Since building from scratch, adapting and keeping updated this Table 1. Main ontology-based context modeling approaches taxonomy manually would be highly costly, we propose to make use of collaboratively created, consensual and up-to-date Ref. Context categories repositories available on the Web. In particular, we propose to use Core categories: Person, Agent, Policy, Event, Action, Time, Space, Semantic Web-based repositories published in Linked Data [7], and Geo-spatial [10] more specifically, DBpedia [15], a multi-domain ontology and Extended categories: Schedule, Meeting, Contact Preference, knowledge base created from the structured data of Wikipedia. Conditional Belief, Region, Priority An important characteristic of DBpedia is that a large amount of A two-level context ontology model, with a generic level and a its data is expressed using the SKOS (Simple Knowledge domain-specific level [9] Organization System) vocabulary, a W3C standard model for Basic context descriptors: User, Resource, Location, Service, Activity, Device, Network taxonomies. By means of SKOS relations, it is possible to traverse related DBpedia categories in a hierarchical (i.e., category- Instantiating the W4 model components: Who, What, Where, When subcategory) fashion. Selecting appropriate “root” categories in As contextual components, Where is associated to the location of the [8] fact (What) performed by the subject (Who), and Where refers to the DBpedia (e.g., dbc:Places2 for locations), and iteratively time or time range associated to the fact. traversing subcategories –under certain restrictions–, our method Mapping between the 5W1H model components –Who, What, automatically builds the target taxonomy, e.g., establishing that [13] Where, When, Why, How– to context items, e.g., Role, Action, dbc:Buildings_and_structures and dcb:Landforms are Status, Location, Time, Goal subcategories of dbc:Places. We surveyed previous work regarding context modeling with the Table 2. Context dimensions and their root DBpedia categories aim of identifying the context dimensions considered in the literature. For each of the identified dimensions, we searched for Context dimension Root categories representative DBpedia categories as root categories of the dbc:Places taxonomy. Next, our approach iteratively performs online queries dbc:Earth to DBpedia for acquiring subcategories that are included in the Location dbc:Types_of_roads context dbc:Academic_institutions taxonomy. To assist the process, we developed a software tool dbc:Transport_by_mode that allows browsing and modifying the taxonomy, as well as dbc:Wheeled_vehicles establishing the criteria that determine which (sub)categories Time dbc:Periodic_phenomena represent context. context dbc:Working_time 2.1 Building the context taxonomy Environmental dbc:Meteorological_phenomena In the literature, there are several context modeling proposals, dbc:Entertainment context dbc:Domesticated_animals particularly in the area of pervasive and ubiquitous computing. Revising published work, we found that a major approach for Social dbc:Interpersonal_relationships context dbc:Emotions context modeling is the use of taxonomies/ontologies. Table 1 summarizes some important context modeling approaches, briefly It is important to note that DBpedia allowed us to retrieve not only describing the context categories they consider. Based on the related, more specific categories by means of the skos:broader analyzed models, we decided to include four major context property, but also instances/individuals of the categories by means dimensions, namely Location, Time, Environmental, and Social of the dct:subject property. Thus, the gathered vocabulary in contexts, which will have a variety of context categories. Table 2 the context taxonomy goes beyond the category names. shows the DBpedia categories selected as the root taxonomy As illustrative examples, for the case of Location context and its categories for each of the above contexts. root category dbc:Wheeled_vehicles, our approach identified the subcategories dbc:Automobiles and dbc:Buses, among others. For the subcategory dbc:Automobiles, it also acquired instances such as dbr:Automobile3, dbr:Car, and dbr:Motorcar, 2 dbc: is a prefix that stands for 3 http://dbpedia.org/resource/Category: dbr: is a prefix that stands for as well as particular vehicles, e.g. dbr:Ferrari_F40 (belonging modified by a first-person possessive determiner, my or our, and the to subcategories like dbc:1990s_automobiles and dbc:Coupes). sentences that have a noun phrase composed by a preposition for, to or with followed by a first-person personal pronoun, me or us. Our tool provides a Context Taxonomy Editor, shown in Figure 1 (left), which browses the taxonomy, and allows the user for On each selected sentence, we first extracted candidate (simple or expanding and removing any of its categories (and corresponding compound) words that may represent contextual conditions. The subcategories and instances) by online querying DBpedia. It also words used by users for describing context are nouns –e.g., allows for establishing criteria that the category names have to be evening, Saturday, restaurant, wife–, and some adjectives –e.g., satisfied to be explored or discarded by our approach. Specifically, sunny, cold, happy, nervous. Again, we used CoreNLP, and it lets defining syntactic patterns “starts with”, “contains” and “ends specifically its Part-Of-Speech tagger, to obtain the above words. with” to explore/discard the categories whose names respectively 3.2 Mapping words to context categories start with, contain, and end with certain text; for instance, expanding For every candidate word, our approach establishes whether or not those categories whose names end with the suffix _transport, like the word matches certain category of the context taxonomy. In dbc:Road_transport and dbc:Rail_transport (which are positive cases, as explained below, it generates scores that reflect subcategories of dbc:Transport_by_mode, the root category of the the relatedness between the words and the matched categories. The Location context). Moreover, the tool allows for setting the resultant (word, category, score) tuples will be the context maximum depth of the taxonomy. annotations of the input reviews. The process is done as follows. 2.2 Enriching the context taxonomy For a fast identification of matches between review words and After navigating through the built taxonomy, we observed that taxonomy categories, we took advantage of Apache Lucene4, a there exist words describing context that were not represented as well-known information retrieval software library. Hence, before either categories or instances of the taxonomy. We realized that, performing any word-category matching, we used Lucene to create in many cases, such words were synonyms of already included a search index for the context taxonomy. Specifically, for each categories/instances. For this reason, we decided to enrich the taxonomy category, we created a text document containing the taxonomy with such synonyms. Specifically, we obtained them name of the category, the names of the instances in the category, from the well-known WordNet English lexical database [19]. and the synonyms of the category. We then added such document We also detected that some morphological derivations of certain into the index. In this way, given a candidate word as input, a search words describing context were not included in the taxonomy, but in the Lucene index returns a ranked list of documents containing were DBpedia entities that could be retrieved via the the word, i.e., a ranked list of categories related to the word. dbo:wikiPageRedirects property, e.g., dbr:Happy redirects to In order to deal with morphological derivations –e.g. singular and dbr:Happiness. We thus further enriched the taxonomy with plural forms of a word–, and user misspellings or deliberated word entities redirected by those already included in it. Table 3 shows modifications –e.g. repeating the last vowel of a word as emphasis–, the number of categories and instances of the final taxonomy. the words to be indexed were first lemmatized. For this reason, to Table 3. Statistics of the built taxonomy effectively map a word with its corresponding context category, we further analyzed the document words retrieved by Lucene and to be DBpedia categories 574 DBpedia instances 9591 compared with the queried candidate words. Specifically, for such Category WordNet synonyms 846 Instance WordNet synonyms 2560 pairs of words, (𝑤! , 𝑤! ), we computed the Damerau-Levenshtein distance [11][16], which measures the edit distance between two Total categories 1420 Redirected DBpedia instances 4578 strings considering the minimum number of insertions, deletions, Total instances 16729 substitutions or transpositions of characters required to transform one string into the other. If the computed distance was lower or 3. CONTEXT ANNOTATION OF REVIEWS equal than certain threshold, then the similarity between the words The built taxonomy is used by our approach to identify and was calculated as sim (𝑤! , 𝑤! ) = (𝐿 − 2 ∗ 𝐷)/𝐿, where 𝐷 is the annotate in reviews those words that express user contextual Damerau-Levenshtein distance between 𝑤! and 𝑤! , and 𝐿 = conditions, in particular, those words that correspond to (the min length 𝑤! , length 𝑤! . The category with the most similar names of) categories or instances in the taxonomy. For such word to the candidate was chosen as the annotated context variable, purpose, we follow two steps: first, selecting a limited number of and the candidate word and its similarity were respectively taken as words that could represent context and second, if possible, the context value and score of the annotation. mapping such words to taxonomy categories. 4. EXPERIMENTS 3.1 Selecting candidate context words To preliminary assess the correctness of the context annotations In order to avoid wrong context annotations, we did not analyze all generated by our approach, and their potential utility for the sentences in the reviews, but only those that express personal recommendation, we conducted two experiments, namely a manual statements and opinions of the review author, e.g., “I watched the validation of annotations, and an offline evaluation of a state-of-the- movie with my children at home,” where children and home would art context-aware recommendation model fed with the annotations. be annotated as social and location contexts, respectively. In both experiments, we used part of the Amazon reviews dataset5 To select such sentences, we made use of the Stanford CoreNLP published in [18], whose data span a period of 18 years, including toolkit [17]. Among other functionalities, CoreNLP generates the ~34.69 million text reviews (and corresponding 1-5 scale ratings) phrase structure tree of a sentence. Applying it to the sentences of up to March 2013, provided by ~6.64 million users for ~2.44 the reviews, we processed the generated trees, and gathered the sentences where the subject is a first-person personal pronoun, I or 4 we, the sentences where the subject is a noun phrase whose head is Apache Lucene information retrieval software library, http://lucene.apache.org 5 Amazon reviews dataset, http://dbpedia.org/resource/ http://snap.stanford.edu/data/web-Amazon.html million products. Specifically, we executed our approach to Matrix Factorization (CAMF) context modeling algorithm [4]. We annotate the context of the first 100,000 reviews of each of the used the implementations of those algorithms provided by the book, movie and music product review sets. CARSKit context-aware recommendation engine [21]. From the 100,000 reviews in each domain, we selected reviews 4.1 Validating the context annotations having annotations from the social, location and time context, as Before evaluating the utility of the generated context annotations they showed best rate of correct context annotations. The final in recommendation, we assessed a subset of them manually. For books, movies and music dataset used were respectively this, we used a Context Annotation Validator implemented in our composed of 17,543, 15,983 and 14,194 reviews, 16,701, 14,340 software tool. Shown in Figure 1 (right), the tool allows the user and 12,332 users, 307, 306 and 2,540 products. Table 5 shows the to load and view a review together with its metadata (id, title, achieved MAE and RMSE values for the recommendation summary). In a left panel with the review text, the words methods in each domain using 5-fold cross-validation. Light gray annotated as context are highlighted. A table on a right panel indicate lower error when applying IS over the corresponding details such annotations, showing the annotated word, the baseline. Dark gray indicate the lowest error in the corresponding associated context category, the type of match (category, instance, column. synonym) and the similarity score for each annotation. In the table, the user is allowed to validate whether an annotated word is Table 5. Rating prediction results of collaborative filtering context or not and, in positive cases, state whether the assigned baselines and context-aware algorithms context is correct, wrong or can be improved with a child or books movies music parent category. Moreover, the tool also allows adding manual annotations, with the possibility of browsing the taxonomy and Method MAE RMSE MAE RMSE MAE RMSE searching for categories and instances on an interactive panel. UB-kNN 0.8889 1.1283 0.8851 1.1590 0.7939 1.0526 From the set of annotated reviews, we carefully read and IB-kNN 0.8751 1.1339 0.8566 1.1623 0.7759 1.0556 manually assessed annotations in book, movie and music reviews. Table 4 shows the number of evaluated reviews and annotations, MF 0.8041 1.0759 0.8242 1.1250 0.7226 1.0179 and the percentage of such annotations that were correct/context. UB-kNN 0.8889 1.1284 0.8853 1.1578 0.7938 1.0524 + IS Table 4. Statistics and effectiveness of context annotations IB-kNN 0.8753 1.1337 0.8576 1.1620 0.7769 1.0561 books movies music + IS MF + IS 0.8036 1.0743 0.8218 1.1230 0.7216 1.0148 Evaluated reviews 86 148 57 CAMF 0.7773 1.1829 0.7635 1.2215 0.6714 1.1111 Evaluated annotations 100 171 86 Percentage of correct annotations 81.0% 86.6% 84.9% We observe that the extracted context data enable improving recommendation quality in the three domains, particularly in the Percentage of context annotations 29.0% 35.7% 45.3% case of CAMF, and also in the case of IS over MF, preliminary Number of manually added annotations 11 15 15 showing the potential of our approach. For more argued conclusions, we should extend the experiments We observe that our approach obtained a relative high percentage with other context-aware recommendation methods, and of correct mapping cases (84.2% on average), and that most of the alternative evaluation metrics (e.g., ranking-based) and protocols. wrong cases were due to semantic ambiguities, which we will We also have to analyze results for each context dimension address in the future. The predominant contexts were social (location, time, environmental, and social) separately to conclude contexts in book reviews (e.g., daughter), location contexts in which of them is more/less useful in each domain. movie reviews (e.g., theater), and emotional contexts (e.g., melancholy) in music reviews. 5. CONCLUSIONS AND FUTURE WORK We also notice that the number of annotations that really referred In this paper we have presented first a method and a software tool to context was low (36.7% on average). We believe that other to semi-automatically build a context taxonomy with Linked Data. domains, such as restaurant and hotel reviews, may have much The taxonomy could be exploited by context-aware applications more contextual information, and thus should be investigated. distinct to recommendation. Moreover, the proposed method As a lesson learnt from the conducted validation, we saw the need could be used to build other types of taxonomies. For instance, it of investigating additional syntactic patterns with which selecting may be instantiated to describe features/aspects of items, and thus the sentences to be analyzed and annotated; for instance, we found it may be exploited in feature-based opinion mining and out contextualized sentences with a third-person subject, such as recommendation applications. the reader/viewers…, and anyone interested in/looking for…, and Using the built taxonomy, we have developed a method to extract contextualized sentences with two-person phrases like if you... and annotate context in user reviews. We manually assessed some of the annotations, and preliminary evaluated the utility of the 4.2 Exploiting the context annotations for annotations in recommendation. We tested them with Item recommendation Splitting and Context-Aware Matrix Factorization algorithms. We In order to get initial insights about the potential benefits of are interested in evaluating additional context-aware exploiting our context annotations in CARS, we evaluated their recommendation techniques as well, and we also want to perform effect on collaborative filtering by means of the Item Splitting (IS) an exhaustive experimentation and result analysis comparing context pre-filtering algorithm [3]. Hence, for each of the three alternative approaches to index and match the context taxonomy considered domains, we evaluated the standard user-based (UB) and categories in the annotation process. item-based (IB) k-nearest neighbor (kNN) and matrix factorization (MF) algorithms with the ratings of the reviews before and after processed by IS. Further, we also evaluated the Context Aware ACKNOWLEDGEMENTS Ontologies for Agents: Theory and Experiences, pp. 233– This work was supported by the Spanish Ministry of Economy, 258. Industry and Competitiveness (TIN2016-80630-P), and by [11] Damerau, F. 1964. A technique for computer detection and Dirección de Investigación, Universidad del Bío-Bío (DIUBB- correction of spelling errors. Communications of the ACM 151115 4/R and GI 170315/EF). 7(3): 171–176. [12] Hariri, N., Mobasher, B., Burke, R., and Zheng, Y. 2011. REFERENCES Context-aware recommendation based on review mining. In [1] Adomavicius, G., Mobasher, B., Ricci, F., and Tuzhilin, A. Proceedings of the 9th Workshop on Intelligent Techniques 2011. Context-aware recommender systems. AI Magazine for Web Personalization and Recommender Systems, pp. 32(3): 67–80. 30–36. [2] Adomavicius, G., and Tuzhilin, A. 2015. Context-aware [13] Kim, J. D., Son, J., and Baik, D.K. 2012. CA5W1H onto: recommender systems. In Ricci, F., Rokach, L., and Ontological context-aware model based on 5W1H. Shapira, B. (Eds.), Recommender Systems Handbook – 2nd International Journal of Distributed Sensor Networks, edition, pp. 191–226. article ID 247346, 11. [3] Baltrunas, L., and Ricci, F. 2009. Context-based splitting of [14] Lahlou, F. Z., Benbrahim, H., Mountassir, A., and Kassou, item ratings in collaborative filtering. In Proceedings of the I. 2013. Inferring context from users’ reviews for context 3rd ACM Conference on Recommender Systems, pp. 245– aware recommendation. In Proceedings of the 33th SGAI 248. International Conference on Innovative Techniques and [4] Baltrunas, L. Ludwig, B. and Ricci, F. 2011. Matrix Applications of Artificial Intelligence, pp. 227–239. factorization techniques for context-aware recommendation. [15] Lehmann, J., Isele, R., Jakob, M., Jentzsch, A., Kontokostas, In Proceedings of the 5th ACM Conference on D., Mendes, P. N., Hellman, S., Morsey, M., van Kleef, P., Recommender Systems, pp. 301–304. Auer, S. & Bizer, C. 2015. DBpedia – a large-scale, [5] Bauman, K., and Tuzhilin, A. 2014. Discovering contextual multilingual knowledge base extracted from Wikipedia. information from user reviews for recommendation Semantic Web 6(2): 167–195. purposes. In Proceedings of the 1st Workshop on New [16] Levenshtein, V. 1966. Binary codes capable of correcting Trends in Content-based Recommender Systems, pp. 2–8. deletions, insertions, and reversals. Soviet Physics Doklady [6] Braunhofer, M., Fernández-Tobías, I., Ricci, F. 2015. 10(8): 707–710. Parsimonious and adaptive contextual information [17] Manning, C. D., Surdeanu, M., Bauer, J., Finkel, J., Bethard, acquisition in recommender systems. In Proceedings of the S. J., and McClosky, D. 2014. The Stanford CoreNLP Joint Workshop on Interfaces and Human Decision Making Natural Language Processing toolkit. In Proceedings of the for Recommender Systems, pp. 2–8. 52nd Annual Meeting of the Association for Computational [7] Bizer, C., Heath, T., and Berners-Lee, T. 2009. Linked Data Linguistics: System Demonstrations, pp. 55–60. - The story so far. International Journal on Semantic Web [18] McAuley, J., and Leskovec, J. 2013. Hidden factors and and Information Systems 5(3), 1–22. hidden topics: Understanding rating dimensions with review [8] Castelli, G., Rossi, A., Mamei, M., and Zambonelli, F. 2007. text. In Proceedings of the 7th ACM Conference on A simple model and infrastructure for context-aware Recommender Systems, pp. 165–172. browsing of the world. In Proceedings of the 5th IEEE [19] Miller, G. A. 1995. WordNet: A lexical database for Conference on Pervasive Computing and Communications, English. Communications of ACM 38(11), 39–41. 1–11. [20] Panniello, U., Gorgoglione, M., Tuzhilin, A. 2016. In [9] Chaari, T., Dejene, E., Laforest, F., and Scuturici, V.-M. CARSs we trust: How context-aware recommendations 2007. A comprehensive approach to model and use context affect customers’ trust and other business performance for adapting applications in pervasive environments. measures of recommender systems. Information Systems International Journal of Systems and Software 80(12): Research 27(1), 182–196. 1973–1992. [21] Zheng, Y., Mobasher, B., Burke, R. 2015. CARSKit: A [10] Chen, H., Finin, T. and Joshi, A. 2005. The SOUPA java-based context-aware recommendation engine. In ontology for pervasive computing. In Tamma, V., Proceedings of the 15th IEEE International Conference on Cranefield, S., Finin, T. W., and Willmott, S. (Eds.), Data Mining Workshops, 1668–1671.