compactcorpus

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: BSD-2-Clause Imports: 14 Imported by: 5

README

The Go package compactcorpus provides a reader and writer for corpora in the compact Alpino format.

See: http://github.com/rug-compling/alpinocorpus

Install

go get github.com/pebbe/compactcorpus

Docs

Documentation

Overview

Package compactcorpus provides a reader and writer for corpora in the compact Alpino format.

See: http://github.com/rug-compling/alpinocorpus

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Corpus

type Corpus struct {
	// contains filtered or unexported fields
}

func Open

func Open(name string) (corpus *Corpus, err error)

Open a compact corpus for reading in simple mode.

Use this version if you want to retrieve most or all items from the corpus, and if you have enough memory to unpack the complete corpus into memory. Otherwise, use: RaOpen()

func (*Corpus) Get

func (c *Corpus) Get(name string) (xml []byte, err error)

Get a named item from the corpus

func (*Corpus) NewRange

func (c *Corpus) NewRange() (r *Range, err error)

Return an iterator for the corpus

type RaCorpus

type RaCorpus struct {
	// contains filtered or unexported fields
}

func RaOpen

func RaOpen(name string) (corpus *RaCorpus, err error)

Open a compact corpus for reading in random access mode.

You need to call Close() when you are done.

Use this version if you want to retrieve only a few items from the corpus, or if you don't have enough memory to unpack the complete corpus into memory. Otherwise, use: Open()

func (*RaCorpus) Close

func (c *RaCorpus) Close()

Close the corpus. This is necessary for freeing files

func (*RaCorpus) Get

func (c *RaCorpus) Get(name string) (xml []byte, err error)

Get a named item from the corpus

func (*RaCorpus) NewRange

func (c *RaCorpus) NewRange() (r *RaRange, err error)

Return an iterator for the corpus

type RaRange

type RaRange struct {
	// contains filtered or unexported fields
}

func (*RaRange) HasNext

func (r *RaRange) HasNext() bool

Return true if there are more items available

func (*RaRange) Next

func (r *RaRange) Next() (name string, xml []byte, err error)

Return the next available item

type Range

type Range struct {
	// contains filtered or unexported fields
}

func (*Range) HasNext

func (r *Range) HasNext() bool

Return true if there are more items available

func (*Range) Next

func (r *Range) Next() (name string, xml []byte)

Return the next available item

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewCorpus

func NewCorpus(filename string) (*Writer, error)

Start creating a new corpus. The corpus will not be written completely until Close() is called.

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(name string, xml []byte) error

func (*Writer) WriteFile

func (w *Writer) WriteFile(filename string) error

func (*Writer) WriteString

func (w *Writer) WriteString(name string, xml string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL