Github user hhbyyh commented on a diff in the pull request:
https://github.com/apache/spark/pull/19599#discussion_r147562600
--- Diff: mllib/src/main/scala/org/apache/spark/ml/param/params.scala ---
@@ -440,6 +440,43 @@ class BooleanParam(parent: String, name: String, doc:
String) // No need for isV
* Specialized version of `Param[Array[String]]` for Java.
*/
@DeveloperApi
+private[ml] class StringParam(parent: Params, name: String, doc: String,
isValid: String => Boolean)
+ extends Param[String](parent, name, doc, isValid) {
+
+ private var options: Option[Array[String]] = None
+
+ def this(parent: Params, name: String, doc: String) =
+ this(parent, name, doc, ParamValidators.alwaysTrue)
+
+ /** construct a StringParam with limited options (case-insensitive) */
+ def this(parent: Params, name: String, doc: String, options:
Array[String]) = {
+ this(parent, name, doc + s" Supported options (case-insensitive):
${options.mkString(", ")}.",
+ s => options.exists(s.equalsIgnoreCase))
--- End diff --
Though `options.exists(s.equalsIgnoreCase))` and
`options.map(_.toLowerCase(Locale.ROOT)).contains(s.toLowerCase(Locale.ROOT))`
should be essentially the same. IMO we still need to stick to just one of them
thoroughly, which also depends on how to do param comparison (switch) in
Estimators.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]