Best machine learning technique for matching product strings

My first thought is to try to parse the names into a description of features (company LG, size 42 Inch, resolution 1080p, type LCD HDTV). Then you can match these descriptions against each other for compatibility; it’s okay to omit a product number but bad to have different sizes. Simple are-the-common-attributes-compatible might be enough, or … Read more

How to match accented characters with a regex?

Instead of \w, use the POSIX bracket expression [:alpha:]: “blåbær dèjá vu”.scan /[[:alpha:]]+/ # => [“blåbær”, “dèjá”, “vu”] “blåbær dèjá vu”.scan /\w+/ # => [“bl”, “b”, “r”, “d”, “j”, “vu”] In your particular case, change the regex to this: NAME_REGEX = /^[[:alpha:]\s'”\-_&@!?()\[\]-]*$/u This does match much more than just accented characters, though. Which is a … Read more

Multiple assignment of non-tuples in scala

All you need to do is make your val side (left of the =) compatible with your initializer (right of the =): scala> val Array(x, y, z) = “XXX,YYY,ZZZ”.split(“,”) x: java.lang.String = XXX y: java.lang.String = YYY z: java.lang.String = ZZZ As you expected, a scala.MatchError will be thrown at runtime if the array size … Read more

Find common prefix of strings

string[] xs = new[] { “h:/a/b/c”, “h:/a/b/d”, “h:/a/b/e”, “h:/a/c” }; string x = string.Join(“https://stackoverflow.com/”, xs.Select(s => s.Split(“https://stackoverflow.com/”).AsEnumerable()) .Transpose() .TakeWhile(s => s.All(d => d == s.First())) .Select(s => s.First())); with public static IEnumerable<IEnumerable<T>> Transpose<T>( this IEnumerable<IEnumerable<T>> source) { var enumerators = source.Select(e => e.GetEnumerator()).ToArray(); try { while (enumerators.All(e => e.MoveNext())) { yield return enumerators.Select(e => e.Current).ToArray(); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)