MCPcopy Index your code
hub / github.com/didasy/tldr

github.com/didasy/tldr @v0.7.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.7.0 ↗ · + Follow
45 symbols 117 edges 10 files 7 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

tldr

When you are too lazy to read the entire text


Coverage Status GoDoc Go Report Card FOSSA Status

What?

tldr is a golang package to summarize a text automatically using lexrank algorithm.

How?

There are two main steps in lexrank, weighing, and ranking. tldr have two weighing and two ranking algorithm included, they are Jaccard coeficient and Hamming distance, then PageRank and centrality, respectively. The default settings use Hamming distance and pagerank.

Is This Fast?

$ go test -bench . -benchmem -benchtime 5s -cpu 4
Running Suite: Tldr Suite
=========================
Random Seed: 1759506557
Will run 8 of 8 specs

••••••••
Ran 8 of 8 Specs in 0.012 seconds
SUCCESS! -- 8 Passed | 0 Failed | 0 Pending | 0 Skipped
goos: linux
goarch: amd64
pkg: github.com/didasy/tldr
cpu: AMD Ryzen 5 5600G with Radeon Graphics
BenchmarkSummarizeCentralityHamming-4               5877            896338 ns/op          177320 B/op       1898 allocs/op
BenchmarkSummarizeCentralityJaccard-4               6562            885374 ns/op          177221 B/op       1898 allocs/op
BenchmarkSummarizePagerankHamming-4                 5832            962000 ns/op          200830 B/op       2086 allocs/op
BenchmarkSummarizePagerankJaccard-4                 5949            962579 ns/op          200865 B/op       2086 allocs/op
PASS
ok      github.com/didasy/tldr  22.840s

So, not bad huh?

Installation

go get github.com/didasy/tldr

Example

package main

import (
    "fmt"
    "io/ioutil"
    "github.com/didasy/tldr"
)

func main() {
    intoSentences := 3
    textB, _ := ioutil.ReadFile("./sample.txt")
    text := string(textB)
    bag := tldr.New()
    result, _ := bag.Summarize(text, intoSentences)
    fmt.Println(result)
}

Testing

To test, just run go test, but you need to have gomega and ginkgo installed.

Dependencies?

tldr depends on pagerank package, and you can install it with go get github.com/alixaxel/pagerank.

License?

Check the LICENSE file. tldr: MIT.

Have fun!

Core symbols most depended-on inside this repo

Summarize
called by 25
tldr.go
New
called by 15
tldr.go
UniqSentences
called by 7
util.go
Intersection
called by 6
util.go
SymmetricDifference
called by 5
util.go
Set
called by 4
tldr.go
SetDictionary
called by 2
tldr.go
SetCustomAlgorithm
called by 2
tldr.go

Shape

Method 20
Function 19
Struct 4
TypeAlias 2

Languages

Go100%

Modules by API surface

tldr.go20 symbols
sort.go10 symbols
util.go7 symbols
tldr_benchmark_test.go5 symbols
tldr_test.go1 symbols
tldr_suite_test.go1 symbols
sentences_test.go1 symbols

For agents

$ claude mcp add tldr \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page