<commit_before>package uiprogress

import (
	"fmt"
	"io"
	"os"
	"time"

	"github.com/gosuri/uilive"
)

// Out is the default writer to render progress bars to
var Out = os.Stdout

// RefreshInterval in the default time duration to wait for refreshing the output
var RefreshInterval = time.Millisecond * 10

// Progress represents the container that renders progress bars
type Progress struct {
	// Out is the writer to render progress bars to
	Out io.Writer

	// Width is the width of the progress bars
	// Width int

	// Bars is the collection of progress bars
	// Bars []*Bar

	// RefreshInterval in the time duration to wait for refreshing the output
	// RefreshInterval time.Duration

	lw *uilive.Writer
	// stopChan chan struct{}
	// mtx      *sync.RWMutex
	bars   chan *Bar
	ticker *time.Ticker
}

// New returns a new progress bar with defaults
func New() *Progress {
	p := &Progress{
		Out:    Out,
		lw:     uilive.New(),
		bars:   make(chan *Bar),
		ticker: time.NewTicker(RefreshInterval),
	}
	go p.server()
	return p
}

// AddBar creates a new progress bar and adds to the container
func (p *Progress) AddBar(total int) *Bar {
	bar := NewBar(total)
	// bar.Width = p.Width
	p.bars <- bar
	return bar
}

// Listen listens for updates and renders the progress bars
func (p *Progress) server() {
	bars := make([]*Bar, 0)
	p.lw.Out = p.Out
loop:
	for {<commit_msg>SetOut<commit_after>package uiprogress

import (
	"fmt"
	"io"
	"os"
	"time"

	"github.com/gosuri/uilive"
)

// Out is the default writer to render progress bars to
// var Out = os.Stdout

// RefreshInterval in the default time duration to wait for refreshing the output
var RefreshInterval = time.Millisecond * 10

// Progress represents the container that renders progress bars
type Progress struct {
	// Out is the writer to render progress bars to
	out io.Writer

	// Width is the width of the progress bars
	// Width int

	// Bars is the collection of progress bars
	// Bars []*Bar

	// RefreshInterval in the time duration to wait for refreshing the output
	// RefreshInterval time.Duration

	lw *uilive.Writer
	// stopChan chan struct{}
	// mtx      *sync.RWMutex
	bars   chan *Bar
	ticker *time.Ticker
}

// New returns a new progress bar with defaults
func New() *Progress {
	p := &Progress{
		out:    os.Stdout,
		lw:     uilive.New(),
		bars:   make(chan *Bar),
		ticker: time.NewTicker(RefreshInterval),
	}
	go p.server()
	return p
}

// SetOut is the writer to render progress bars to
func (p *Progress) SetOut(w io.Writer) *Progress {
	p.out = w
	return p
}

// AddBar creates a new progress bar and adds to the container
func (p *Progress) AddBar(total int) *Bar {
	bar := NewBar(total)
	// bar.Width = p.Width
	p.bars <- bar
	return bar
}

// Listen listens for updates and renders the progress bars
func (p *Progress) server() {
	bars := make([]*Bar, 0)
	p.lw.Out = p.out
loop:
	for {
{'fraction_non_alphanumeric': 0.10236768802228412, 'fraction_numerical': 0.0020891364902506965, 'mean_word_length': 3.1819505094614264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '45532', 'n_tokens_mistral': 984, 'n_tokens_neox': 937, 'n_words': 367}