score:5
Accepted answer
assuming combined
has the type rdd[(string, string)]
, and levenshtein.distance
has this signature:
def distance(s1:string, s2:string)
you can apply it as follows:
val newrdd = combined.map { case (s1, s2) => levenshtein.distance(s1, s2) }
or, alternatively:
val newrdd = combined.map(t => levenshtein.distance(t._1, t._2))
Source: stackoverflow.com
Related Query
- Apply function to Cartesian RDDs
- What is the apply function in Scala?
- How to apply a function to a tuple?
- In Scala, why can't I partially apply a function without explicitly specifying its argument types?
- Cannot create apply function with static language?
- Which function in spark is used to combine two RDDs by keys
- How to apply a function to a column of a Spark DataFrame?
- Scalaz: how can I accumulate Failures or apply a function to Validations with different types?
- how would monadic rules apply if the function could be of a different type
- How to overload scala function apply methods
- How to apply a function of all elements of n Array?
- Spark 1.6 apply function to column with dot in name/ How to properly escape colName
- How to transform and apply a partial function using Scala Macros?
- How to use Apply for Function Application
- Is there a function in scala or scalaz to apply a function to a list if the list is not empty?
- Apply function on each elements in one list using element from others list as argument?
- Flink Streaming - apply function in windows
- In Scala, apply function to values for some keys in immutable map
- spark apply function to columns in parallel
- How to apply function to each tuple of a multi-dimensional array in Scala?
- Apply function to one element only in list or array in Scala
- Using apply ("()") on function passed in by-name parameter: evaluation is not forced?
- Scala - Function apply vs match clause
- How to apply sequence function to List of ValidatedNel in cats?
- Spark and Scala: Apply a function to each element of an RDD
- Apply function on unlimited parameters
- Implicit def of Any to Function adds apply method to classes
- How to apply a function for the first certain elements of an array in Scala?
- How can I view the code that Scala uses to automatically generate the apply function for case classes?
- Conditionally apply a function in Scala - How to write this function?
More Query from same tag
- How do I get the implicit instance of the VectorSpace I need?
- Generate a Confusion Matrix in Spark Scala implementing RandomForest of MLlib
- LinearSeqOptimized#find Reference Copy
- Create a nested fields and store dataframe to MongoDB using scala?
- Compatible buildpacks for Scala Playframework application
- printing column names that are different in a dataframe
- Scala, the java of the future(?)
- SBT resolver for oss.sonatype.org not working
- What would be the best language/library choice for writing a scalable webservice server?
- Iterate through List of case objects replace NaNs and write it back in Scala
- Json implicit Reads: type mismatch?
- Parser Combinators for Trees instead of Strings
- scala: adding a method to List?
- How to fetch data for Optional List of custom data type in cassandra using Websudos Phanthom
- scala function not called from lambda function
- How to save string as json in scala spark
- How to append an index column to a spark data frame using spark streaming in scala?
- Why doesn't "foldLeft" work with class members in Scala?
- Isn't lambda function also an object with Function1 trait?
- spray set content-type for XML
- How to run code before/after cucumber suite?
- Find Indexes *Where*
- Why should Map implementations override foreach?
- Clean exception handling in Scala
- Transforming scala Flatten to use in Java in Spark
- Any concise way to define a constant function (mapping) in scala
- Polymorphic instantiation in Scala using TypeTag and ClassTag
- df.show() Not printing to file
- How to restrict nestead markup in Regex and Parser combinator?
- Scala programmer - "should there be one obvious way to do it" or "more than one way to do it"?