alpinods

package module
v1.16.4 Latest Latest
Warning

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

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

README

The Go package alpinods implements the type AlpinoDS that can be used to marshal and unmarshal XML files in the alpino_ds format, using the encoding/xml package.

See: https://www.let.rug.nl/~vannoord/alp/Alpino/

Go Report Card GoDoc

Documentation

Overview

Package alpinods implements the type AlpinoDS that can be used to marshal and unmarshall XML files in the alpino_ds format, using the package encoding/xml.

The field UserData in several places can be used for storing processing information.

About Alpino, see: https://www.let.rug.nl/~vannoord/alp/Alpino/

Index

Constants

View Source
const DtdVersion = "1.16"

DtdVersion defines the highest supported alpino_ds.dtd version.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlpinoDS added in v1.11.0

type AlpinoDS struct {
	XMLName  xml.Name  `xml:"alpino_ds"`
	Version  string    `xml:"version,attr,omitempty"`
	Metadata *Metadata `xml:"metadata,omitempty"`
	Parser   *Parser   `xml:"parser,omitempty"`
	Node     *Node     `xml:"node,omitempty"`
	Sentence *Sentence `xml:"sentence,omitempty"`
	Comments *Comments `xml:"comments,omitempty"`
	Root     []*Deprel `xml:"root,omitempty"`
	Conllu   *Conllu   `xml:"conllu,omitempty"`

	UserData interface{} `xml:"-"`
}

The AlpinoDS type encodes a complete document in the alpino_ds XML format.

func Reduce added in v1.16.3

func Reduce(alpino *AlpinoDS) *AlpinoDS

Reduce returns a minimal copy of an AlpinoDS document.

Entities and atttributes that are not used in de reduced feature set of the minimal Alpino plug-in for TrEd are removed.

The document version is set to 1.5

see: https://www.let.rug.nl/vannoord/alp/Alpino/tred/

func (*AlpinoDS) Enhance added in v1.16.1

func (a *AlpinoDS) Enhance(f Features)

Enhance enriches an AlpinoDS document with structural information that is not provided by the Alpino parser.

In addition, it sets the document version to DtdVersion.

Old values for the chosen options are erased.

func (AlpinoDS) String added in v1.11.0

func (a AlpinoDS) String() string

The String method returns the AlpinoDS type as a complete, cleaned-up, and formatted XML document.

type Attr added in v1.16.0

type Attr struct {
	Name  string
	Value string
}

type Attrib added in v1.16.2

type Attrib struct {
	Field string
	Name  string
}

func Attribs added in v1.16.2

func Attribs() []Attrib

Attribs return a list of all Node attributes, field and name. Useful for code generation

type Comments

type Comments struct {
	Comment []string `xml:"comment,omitempty"`
}

The Comments type encodes `/alpino_ds/comments`.

type Conllu

type Conllu struct {
	Conllu string `xml:",cdata"`
	Status string `xml:"status,attr,omitempty"`
	Error  string `xml:"error,attr,omitempty"`
	Auto   string `xml:"auto,attr,omitempty"`
}

The Conllu type encodes `/alpino_ds/conllu`.

type Data added in v1.12.0

type Data struct {
	Name string `xml:"name,attr,omitempty"`
	Data string `xml:",chardata"`

	UserData interface{} `xml:"-"`
}

The Data type encodes `alpino_ds//node/data`

type Dep

type Dep struct {
	ID         string `xml:"id,attr,omitempty"`
	Head       string `xml:"head,attr,omitempty"`
	Deprel     string `xml:"deprel,attr,omitempty"`
	DeprelMain string `xml:"deprel_main,attr,omitempty"`
	DeprelAux  string `xml:"deprel_aux,attr,omitempty"`
	Elided     bool   `xml:"elided,attr,omitempty"`

	UserData interface{} `xml:"-"`
}

The Dep type encodes `/alpino_ds//node/ud/dep`.

type Deprel

type Deprel struct {
	XMLName xml.Name

	RecursionLimit string `xml:"recursion_limit,attr,omitempty"`

	Ud    string `xml:"ud,attr,omitempty"`
	ID    string `xml:"id,attr,omitempty"`
	Form  string `xml:"form,attr,omitempty"`
	Lemma string `xml:"lemma,attr,omitempty"`
	Upos  string `xml:"upos,attr,omitempty"`
	Feats
	Head      string `xml:"head,attr,omitempty"`
	Deprel    string `xml:"deprel,attr,omitempty"`
	DeprelAux string `xml:"deprel_aux,attr,omitempty"`

	DeprelAttributes

	Deps []*Deprel `xml:",any"`

	UserData interface{} `xml:"-"`
}

The Deprel type encodes `/alpino_ds/root` and its descendants.

type DeprelAttributes

type DeprelAttributes struct {
	Buiging  string `xml:"buiging,attr,omitempty"`
	Conjtype string `xml:"conjtype,attr,omitempty"`
	Dial     string `xml:"dial,attr,omitempty"`
	Genus    string `xml:"genus,attr,omitempty"`
	Getal    string `xml:"getal,attr,omitempty"`
	GetalN   string `xml:"getal-n,attr,omitempty"`
	Graad    string `xml:"graad,attr,omitempty"`
	Lwtype   string `xml:"lwtype,attr,omitempty"`
	Naamval  string `xml:"naamval,attr,omitempty"`
	Npagr    string `xml:"npagr,attr,omitempty"`
	Ntype    string `xml:"ntype,attr,omitempty"`
	Numtype  string `xml:"numtype,attr,omitempty"`
	Pdtype   string `xml:"pdtype,attr,omitempty"`
	Persoon  string `xml:"persoon,attr,omitempty"`
	Positie  string `xml:"positie,attr,omitempty"`
	Pt       string `xml:"pt,attr,omitempty"`
	Pvagr    string `xml:"pvagr,attr,omitempty"`
	Pvtijd   string `xml:"pvtijd,attr,omitempty"`
	Spectype string `xml:"spectype,attr,omitempty"`
	Status   string `xml:"status,attr,omitempty"`
	Vwtype   string `xml:"vwtype,attr,omitempty"`
	Vztype   string `xml:"vztype,attr,omitempty"`
	Wvorm    string `xml:"wvorm,attr,omitempty"`
}

The DeprelAttributes type encodes attributes that are copied from `/alpino_ds//node` into `/alpino_ds/root` and its descendants.

type Feats

type Feats struct {
	Abbr     string `xml:"Abbr,attr,omitempty"`
	Case     string `xml:"Case,attr,omitempty"`
	Definite string `xml:"Definite,attr,omitempty"`
	Degree   string `xml:"Degree,attr,omitempty"`
	Foreign  string `xml:"Foreign,attr,omitempty"`
	Gender   string `xml:"Gender,attr,omitempty"`
	Number   string `xml:"Number,attr,omitempty"`
	Person   string `xml:"Person,attr,omitempty"`
	PronType string `xml:"PronType,attr,omitempty"`
	Reflex   string `xml:"Reflex,attr,omitempty"`
	Tense    string `xml:"Tense,attr,omitempty"`
	VerbForm string `xml:"VerbForm,attr,omitempty"`
}

The Feats type encodes the standard UD features that are used in Alpino.

type Features added in v1.16.1

type Features uint

Features defines a set of flags to pass to the method AlpinoDS.Enhance()

const (
	Fnp       Features = 1 << iota                  // Add attribute `is_np`
	Fvorfeld                                        // Add attribute `is_vorfeld`
	Fnachfeld                                       // Add attribute `is_nachfeld`
	Fall      Features = Fnp | Fvorfeld | Fnachfeld // All of the above
)

type Meta

type Meta struct {
	Type  string `xml:"type,attr"`
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`

	UserData interface{} `xml:"-"`
}

The Meta type encodes `/alpino_ds/metadata/meta`.

type Metadata

type Metadata struct {
	Meta []Meta `xml:"meta,omitempty"`
}

The Metadata type encodes `/alpino_ds/metadata`.

type Node

type Node struct {
	NodeAttributes
	Data []*Data `xml:"data,omitempty"`
	Ud   *Ud     `xml:"ud,omitempty"`
	Node []*Node `xml:"node"`

	UserData interface{} `xml:"-"`
}

The Node type encodes `/alpino_ds//node`.

func (*Node) Attrs added in v1.16.0

func (node *Node) Attrs() []Attr

The Attrs method returns a list of non-nil attributes of node

type NodeAttributes

type NodeAttributes struct {
	Aform        string `xml:"aform,attr,omitempty"`
	Begin        int    `xml:"begin,attr"`
	Buiging      string `xml:"buiging,attr,omitempty"`
	Case         string `xml:"case,attr,omitempty"`
	Cat          string `xml:"cat,attr,omitempty"`
	Comparative  string `xml:"comparative,attr,omitempty"`
	Conjtype     string `xml:"conjtype,attr,omitempty"`
	Def          string `xml:"def,attr,omitempty"`
	Dial         string `xml:"dial,attr,omitempty"`
	DroppedAgr   string `xml:"dropped_agr,attr,omitempty"`
	DroppedPrs   string `xml:"dropped_prs,attr,omitempty"`
	Dscmanual    string `xml:"dscmanual,attr,omitempty"`
	Dscsense     string `xml:"dscsense,attr,omitempty"`
	End          int    `xml:"end,attr"`
	Frame        string `xml:"frame,attr,omitempty"`
	Gen          string `xml:"gen,attr,omitempty"`
	Genus        string `xml:"genus,attr,omitempty"`
	Getal        string `xml:"getal,attr,omitempty"`
	GetalN       string `xml:"getal-n,attr,omitempty"`
	Graad        string `xml:"graad,attr,omitempty"`
	His          string `xml:"his,attr,omitempty"`
	His1         string `xml:"his_1,attr,omitempty"`
	His2         string `xml:"his_2,attr,omitempty"`
	His11        string `xml:"his_1_1,attr,omitempty"`
	His12        string `xml:"his_1_2,attr,omitempty"`
	His21        string `xml:"his_2_1,attr,omitempty"`
	His22        string `xml:"his_2_2,attr,omitempty"`
	His111       string `xml:"his_1_1_1,attr,omitempty"`
	His112       string `xml:"his_1_1_2,attr,omitempty"`
	His121       string `xml:"his_1_2_1,attr,omitempty"`
	His122       string `xml:"his_1_2_2,attr,omitempty"`
	His211       string `xml:"his_2_1_1,attr,omitempty"`
	His212       string `xml:"his_2_1_2,attr,omitempty"`
	His221       string `xml:"his_2_2_1,attr,omitempty"`
	His222       string `xml:"his_2_2_2,attr,omitempty"`
	ID           int    `xml:"id,attr"`
	Iets         string `xml:"iets,attr,omitempty"`
	Index        int    `xml:"index,attr,omitempty"`
	Infl         string `xml:"infl,attr,omitempty"`
	IsNachfeld   string `xml:"is_nachfeld,attr,omitempty"`
	IsNp         string `xml:"is_np,attr,omitempty"`
	IsVorfeld    string `xml:"is_vorfeld,attr,omitempty"`
	Lcat         string `xml:"lcat,attr,omitempty"`
	Lemma        string `xml:"lemma,attr,omitempty"`
	Lwtype       string `xml:"lwtype,attr,omitempty"`
	MwuRoot      string `xml:"mwu_root,attr,omitempty"`
	MwuSense     string `xml:"mwu_sense,attr,omitempty"`
	Naamval      string `xml:"naamval,attr,omitempty"`
	Neclass      string `xml:"neclass,attr,omitempty"`
	Npagr        string `xml:"npagr,attr,omitempty"`
	Ntype        string `xml:"ntype,attr,omitempty"`
	Num          string `xml:"num,attr,omitempty"`
	Numtype      string `xml:"numtype,attr,omitempty"`
	Pb           string `xml:"pb,attr,omitempty"`
	Pdtype       string `xml:"pdtype,attr,omitempty"`
	Per          string `xml:"per,attr,omitempty"`
	Personalized string `xml:"personalized,attr,omitempty"`
	Persoon      string `xml:"persoon,attr,omitempty"`
	Pos          string `xml:"pos,attr,omitempty"`
	Positie      string `xml:"positie,attr,omitempty"`
	Postag       string `xml:"postag,attr,omitempty"`
	Pron         string `xml:"pron,attr,omitempty"`
	Pt           string `xml:"pt,attr,omitempty"`
	Pvagr        string `xml:"pvagr,attr,omitempty"`
	Pvtijd       string `xml:"pvtijd,attr,omitempty"`
	Refl         string `xml:"refl,attr,omitempty"`
	Rel          string `xml:"rel,attr,omitempty"`
	Rnum         string `xml:"rnum,attr,omitempty"`
	Root         string `xml:"root,attr,omitempty"`
	Sc           string `xml:"sc,attr,omitempty"`
	Sense        string `xml:"sense,attr,omitempty"`
	SonarNe      string `xml:"sonar_ne,attr,omitempty"`
	SonarNeClass string `xml:"sonar_ne_class,attr,omitempty"`
	SonarNeBegin string `xml:"sonar_ne_begin,attr,omitempty"`
	SonarNeEnd   string `xml:"sonar_ne_end,attr,omitempty"`
	Special      string `xml:"special,attr,omitempty"`
	Spectype     string `xml:"spectype,attr,omitempty"`
	Status       string `xml:"status,attr,omitempty"`
	Stype        string `xml:"stype,attr,omitempty"`
	Tense        string `xml:"tense,attr,omitempty"`
	VPer         string `xml:"v_per,attr,omitempty"`
	Vform        string `xml:"vform,attr,omitempty"`
	Vwtype       string `xml:"vwtype,attr,omitempty"`
	Vztype       string `xml:"vztype,attr,omitempty"`
	Wh           string `xml:"wh,attr,omitempty"`
	Wk           string `xml:"wk,attr,omitempty"`
	Word         string `xml:"word,attr,omitempty"`
	Wvorm        string `xml:"wvorm,attr,omitempty"`
}

The NodeAttributes type encodes the attributes for `/alpino_ds//node`.

type Parser

type Parser struct {
	Build string `xml:"build,attr,omitempty"`
	Date  string `xml:"date,attr,omitempty"`
	Cats  string `xml:"cats,attr,omitempty"`
	Skips string `xml:"skips,attr,omitempty"`
}

The Parser type encodes `/alpino_ds/parser`.

type Sentence

type Sentence struct {
	Sentence string `xml:",chardata"`
	SentID   string `xml:"sentid,attr,omitempty"`
}

The Sentence type encodes `/alpino_ds/sentence`.

type Ud

type Ud struct {
	ID    string `xml:"id,attr,omitempty"`
	Form  string `xml:"form,attr,omitempty"`
	Lemma string `xml:"lemma,attr,omitempty"`
	Upos  string `xml:"upos,attr,omitempty"`
	Feats
	Head       string `xml:"head,attr,omitempty"`
	Deprel     string `xml:"deprel,attr,omitempty"`
	DeprelMain string `xml:"deprel_main,attr,omitempty"`
	DeprelAux  string `xml:"deprel_aux,attr,omitempty"`
	Dep        []Dep  `xml:"dep,omitempty"`

	UserData interface{} `xml:"-"`
}

The Ud type encodes `/alpino_ds//node/ud`.

Jump to

Keyboard shortcuts

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