Code Monkey home page Code Monkey logo

jwz's Introduction

Go Report Card PkgGoDev Release Release Maintenance GitHub license GitHub stars

The JWZ Threading algorithm written in Go

This is an open source Go implementation of the widely known JWZ message threading algorithm originally written by Jamie Zawinsky. See his explanation here

You will find an example of implementing the interface(s) needed to operate this package in the /examples/visualize directory.

See the godoc for examples in documentation form, and the example in examples\visualize

Functionality

The package provides the original JWZ algorithm to implementors of the Threadable interface. It has been tested against many thousands of emails. The interface provides a few extra features over the original Java version, but these are additions and enhancements to the interface, not algorithmic changes.

As well as providing the threading capability itself, the package also provides:

  • A generic walker, to which you can provide a function to operate upon the nodes in the threaded tree.
  • A generic sorter, to which you can provide your own comparison function (a byDate example is provided)

Feel free to report any issues and offer any additions by pull requests.

Quick start

  include "github.com/gatherstars-com/jwz"
  ~/myproject $ go mod tidy
	// Use the enmime package to build all the emails we find under the given directory and store them in a slice
	// of structs which implement the Threadable interface
	//
	//
	threadables, err := buildEnvelopes(testData, sizeHint)
	if err != nil {
		log.Printf("Unable to walk the eml directory: %#v", err)
		os.Exit(1)
	}

	// Now we have a big slice of all the emails, lets use our jwz algorithm to place them in to a thread tree
	//
	threader := jwz.NewThreader()
	sliceRoot, err := threader.ThreadSlice(threadables)
	if err != nil {
		log.Fatalf("Email threading operation return fatal error: %#v", err)
	}

	// Sort it Rodney!
	//
	x := jwz.Sort(sliceRoot, byDate)

An implementation of buildEnvelopes can be found in examples\visualizer\handlers.go

jwz's People

Contributors

jimidle avatar rjarry avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.