Posts tagged 'groovy'

Whiskey Clustering with Groovy and Apache Ignite

In a previous blog post , we looked at using Apache Wayang  (incubating) and Apache Spark to scale up the k-means clustering algorithm. Let's look at another useful technology for scaling up this problem, Apache Ignite . They recently released a new version , but earlier versions are also fine for our example. Before we start, a quick... [Read more...]

Groovy Dates And Times Cheat Sheet

Java has had a Date class from the very beginning and Groovy supports using it and several related classes like Calendar . Throughout this blog post we refer to those classes as the legacy date classes . Groovy enhances the experience of using the legacy date classes with simpler mechanisms for formatting, parsing and extracting fields from the... [Read more...]

Fruity Eclipse Collections

This blog post continues on to some degree from the previous post , but instead of deep learning, we'll look at clustering using k-means after first exploring some top methods of Eclipse Collections with fruit emoji examples. Eclipse Collections Fruit Salad First, we'll define a Fruit enum (it adds one additional fruit compared to the... [Read more...]

Deep Learning and Eclipse Collections

DeepLearning4J and Eclipse Collections revisited In previous blogs, we have covered Eclipse Collections and Deep Learning . Recently, a couple of the highly recommended katas for Eclipse Collections have been revamped to include "pet" and "fruit" emojis for a little bit of extra fun. What could be better than Learning Eclipse... [Read more...]

Deck of cards with Groovy, JDK collections and Ecl...

Once again, Donald Raab has produced an interesting blog post on Eclipse Collections ; this one shows some code for modelling and manipulating cards with Java 17 and Eclipse Collections. His related katas are highly recommended. Here is the same example in Groovy (4.0.5 was used here) with just a few tweaks: enum Rank { ACE , TWO , THREE , ... [Read more...]

Encryption and decryption with Groovy

Inspired by this recent blog entry , here is an example showing how to encrypt and decrypt with Groovy. Using the JDK crypto classes First, we need some text to encrypt. We'll use an excerpt of the one from the aforementioned blog post: var text = 'Contrary to popular belief, Lorem Ipsum is not simply random text. \ It has roots in... [Read more...]

Calculating Fibonacci with Groovy revisited

In a recent post , we looked at using Matrices with Groovy including using matrices to calculate Fibonacci terms. But do you need that complexity to calculate Fibonacci? Not, not at all. You can do various one-liners for that scenario (to repeat the calculation from that post): Stream. iterate ([ 1 , 1 ], f -> [f[ 1 ], f.sum()]).limit( 8... [Read more...]

Solving cryptarithmetic puzzles with Groovy and co...

Introduction When writing solutions to problems, we frequently strive to hide away implementation details. In Object-oriented (OO) programming, we might build a rich hierarchy of classes with well-thought out methods so that our final solution can be expressed in terms of simple nouns and verbs (methods and class instances) in our domain model. When... [Read more...]

Groovy List Processing Cheat Sheet

Declaring lists Several styles are supported for declaring lists: var pets = [ 'cat' , 'canary' , 'dog' , 'fish' , 'gerbil' ] // idiomatic Groovy var nums = [ 1 , 2 , 3 , 4 ] as LinkedList // use 'as' for other kinds of list var primes = List. of ( 2 , 3 , 5 ,... [Read more...]

Matrix calculations with Groovy, Apache Commons Ma...

This blogs looks at performing matrix calculations with Groovy using various libraries:  Apache Commons Math , ojAlgo , EJML , and Nd4j  (part of Eclipse Deeplearning4j ). We'll also take a quick look at using the incubating Vector API for matrix calculations (JEPs  338 , 414 ,  417 ,  426 ). Fibonacci The Fibonacci... [Read more...]

Life on Mars: Units of Measurement systems, Groovy...

The Mars Climate Orbiter was launched in 1998 as part of a multi-faceted Mars exploration program. It was lost due to a trajectory calculation error when nearing Mars. An investigation attributed the failure to a measurement mismatch between two software systems: metric units were used by NASA and US customary units were used by spacecraft builder... [Read more...]

Natural Language Processing with Groovy, OpenNLP, ...

Natural Language Processing is certainly a large and sometimes complex topic with many aspects. Some of those aspects deserve entire blogs in their own right. For this blog, we will briefly look at a few simple use cases illustrating where you might be able to use NLP technology in your own project. Language Detection Knowing what language some... [Read more...]

Detecting objects with Groovy, the Deep Java Libra...

This blog posts looks at using Apache Groovy with the Deep Java Library (DJL) and backed by the Apache MXNet engine to detect objects within an image. (Apache MXNet is an incubating project at the ASF .) Deep Learning Deep learning falls under the branches of machine learning and artificial intelligence . It involves multiple layers... [Read more...]

Working with SQL databases with Groovy and GraalVM

During the week, there was an interesting video and blog post on the latest GraalVM 22.2 Release. The release has numerous new features and improvements including: smaller native executables the ability to generate heap dumps in native executables experimental native image debugging within IntelliJ IDEA the ability to embed a Software Bill of... [Read more...]

Reading and Writing CSV files with Groovy

In this post, we'll look at reading and writing CSV files using Groovy. Aren't CSV files just text files? For simple cases, we can treat CSV files no differently than we would other text files. Suppose we have the following data that we would like to write to a CSV file: def data = [ [ 'place' , 'firstname' , ... [Read more...]

Groovy release train: 4.0.4, 3.0.12, 2.5.18

It's been a productive time for the Apache Groovy project recently. We recently released versions 4.0.4, 3.0.12 and 2.5.18 with 42, 21 and 15 fixes and improvements respectively. Two quick highlights for the 4.0.4 release before getting into more details about the release. Eric Milles has been interacting for many months with the team from the ... [Read more...]

Comparators and Sorting in Groovy

This blog post is inspired by the Comparator examples in the excellent Collections Refuelled talk and blog by Stuart Marks. That blog from 2017 highlights improvements in the Java collections library in Java 8 and 9 including numerous Comparator improvements. It is now 5 years old but still highly recommended for anyone using the Java collections... [Read more...]

Testing your Java with Groovy, Spock, JUnit5, Jaco...

This blog post covers a common scenario seen in the Groovy community which is projects which use Java for their production code and Groovy for their tests. This can be a low risk way for Java shops to try out and become more familiar with Groovy. We'll write our initial tests using the Spock testing framework  and we'll use JUnit5 later with... [Read more...]

Parsing JSON with Groovy

Groovy has excellent support for processing a range of structured data formats like JSON, TOML, YAML, etc. This blog post looks at JSON . There is quite good documentation on this topic as part of the Groovy documentation . There are also numerous online sources for more details including Groovy - JSON tutorial , Working with JSON in Groovy , and ... [Read more...]

Classifying Iris Flowers with Deep Learning, Groov...

A classic data science dataset captures flower characteristics of Iris flowers. It captures the width and length of the sepals and petals for three species ( Setosa , Versicolor , and Virginica ). The Iris project in the groovy-data-science repo is dedicated to this example. It includes a number of Groovy scripts and a Jupyter/BeakerX... [Read more...]

Search blogs.apache.org

Today's active blogs

Popular blog tags

Related sites

Navigation