Code Monkey home page Code Monkey logo

activityenrichment's Introduction

Activity Enrichment

Enrich the User Activity Log with Product details from Product Catalog.

Sample Input

User Activity List = List of raw user activity Strings

val rec1: String = """{
    "visitorId": "v1",
    "products": [{
         "id": "i1",
         "interest": 0.68
    }, {
         "id": "i2",
         "interest": 0.42
    }]
}"""
 
val rec2: String = """{
    "visitorId": "v2",
    "products": [{
         "id": "i1",
         "interest": 0.78
    }, {
         "id": "i3",
         "interest": 0.11
    }]
}"""
 
val visitsData: Seq[String] = Seq(rec1, rec2)

Product Catalog = A dictionary with the product id and product name

val productIdToNameMap = Map("i1" -> "Nike Shoes", "i2" -> "Umbrella", "i3" -> "Jeans")

Expected Output

List of Enriched User Activity Log with Product details.

enrichedRec1 =
"""{
    "visitorId": "v1",
    "products": [{
         "id": "i1",
         "name": "Nike Shoes",
         "interest": 0.68
    }, {
         "id": "i2",
         "name": "Umbrella",
         "interest": 0.42
    }]
}"""
 
enrichedRec2 =
"""{
    "visitorId": "v2",
    "products": [{
         "id": "i1",
         "name": "Nike Shoes",
         "interest": 0.78
    }, {
         "id": "i3",
         "name": "Jeans",
         "interest": 0.11
    }]
}"""


val output: Seq[String] = Seq(enrichedRec1, enrichedRec2)
 

Code Modules

activity-common

Contains the common core module defining UserActivity Model and conversion of UserActivity Object to and from JSON.
Also contains sample data given in the coding test for test suite

enrich-activity

Scala Application to enrich the user activity with product details

Execution: Run the shell script file in ActivityEnrichment/enrich-activity directory

  #cd ActivityEnrichment/enrich-activity
  #./run_enrich_activity.sh

enrich-activity-spark

Spark(Scala) Application to enrich the user activity with product details parallelly

Execution: Run the shell script file in ActivityEnrichment/enrich-activity-spark directory

  #cd ActivityEnrichment/enrich-activity-spark
  #./run_enrich_activity_job.sh

activityenrichment's People

Contributors

lakshmankollipara avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.