build codecov Current Version Scala Steward badge license

Gpc-tree is a library to work with the Google product categories / taxonomy in a tree structure where every node in the tree consists of a placement in the Google Product Taxonomy and its children (if there are any). It can load any of the available lists of Google product categories and has methods to:

  • find a node in the tree
  • find the parent of a node
  • find the path of a node
  • find the common ancestors between nodes
  • reconstruct a line in the taxonomy file


Gpc-tree is published for Scala 2.13. To start using it add the following to your build.sbt:

libraryDependencies += "nl.gn0s1s" %% "gpc-tree" % "0.0.1"

Example usage

import java.nio.charset.StandardCharsets

import nl.gn0s1s.gpctree.GpcTree

val gpcTree = new GpcTree("", StandardCharsets.UTF_8.toString))

gpcTree.findNodeInTree("6975") // res0: Option[nl.gn0s1s.Node] = Some(Node(Placement(6975,Biochemicaliƫn),List()))

gpcTree.findNodeInTree("500105").map(gpcTree.asString) // res1: Option[String] = Some(500105 - Eten, drinken en tabak > Voedselitems > Specerijen en sauzen > Witte en roomsauzen)

// find siblings of a node
gpcTree.findParentInTree("500105").map(_.children) // res2: Option[scala.collection.Seq[nl.gn0s1s.Node]] = Some(List(Node(Placement(6772,Cocktailsaus),List()), Node(Placement(6905,Currysaus),List()), Node(Placement(6845,Dessertsauzen),List(Node(Placement(6854,Fruittoppings),List()), Node(Placement(6844,Siropen voor ijs),List()))), Node(Placement(4947,Honing),List()), Node(Placement(4614,Hot sauce),List()), Node(Placement(500076,Ingelegde vruchten en groenten),List()), Node(Placement(5762,Jus),List()), Node(Placement(2018,Ketchup),List()), Node(Placement(500074,Marinades en grillsauzen),List()), Node(Placement(1568,Mayonaise),List()), Node(Placement(6782,Mierikswortelsaus),List()), Node(Placement(1387,Mosterd),List()), Node(Placement(5760,Olijven en kappertjes),List()), Node(Placement(5759,Pastasauzen),List()),...



The code is available under the Mozilla Public License, version 2.0.