Skip to content

Instantly share code, notes, and snippets.

@bicycle1885
Created November 7, 2015 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bicycle1885/918a0fee5dbb3d68f05a to your computer and use it in GitHub Desktop.
Save bicycle1885/918a0fee5dbb3d68f05a to your computer and use it in GitHub Desktop.
diff --git a/src/TinySegmenter.jl b/src/TinySegmenter.jl
index 7fcb27a..7e73fbb 100644
--- a/src/TinySegmenter.jl
+++ b/src/TinySegmenter.jl
@@ -5,6 +5,11 @@ export tokenize
typealias US UTF8String
+Base.hash(x::Tuple{Char,Char}) = hash((UInt64(x[2]) << 32) | UInt64(x[1]))
+Base.hash(x::Tuple{UInt8,UInt8}) = hash((UInt64(x[2]) << 8) | UInt64(x[1]))
+Base.hash(x::Tuple{UInt8,UInt8,UInt8}) = hash((UInt64(x[3]) << 16) | (UInt64(x[2]) << 8) | UInt64(x[1]))
+Base.hash(x::Tuple{UInt8,UInt8,UInt8,UInt8}) = hash((UInt64(x[4]) << 24) | (UInt64(x[3]) << 16) | (UInt64(x[2]) << 8) | UInt64(x[1]))
+
macro t_str(s)
tuple(s...)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment