english

package
v0.0.0-...-88bd814 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(data []byte) (*fintracts.Contract, error)

Parse parses the contract in English to the JSON format.

Types

type Agreement

type Agreement struct {
	BondPurchase     *BondPurchase     `parser:"'Hereby' 'enter' 'in' ( 'a' 'Bond' 'Purchase' 'Agreement' 'defined' 'as' 'follows' ':' @@ "`
	InterestRateSwap *InterestRateSwap `parser:"| 'an' 'Interest' 'Rate' 'Swap' 'Transaction' 'Agreement' 'defined' 'as' 'follows' ':' @@"`
	CurrencySwap     *CurrencySwap     `parser:"| 'a' 'Currency' 'Swap' 'Transaction' 'Agreement' 'defined' 'as' 'follows' ':' @@ )"`
}

type BondPurchase

type BondPurchase struct {
	Issuer       string   `parser:"@Ident 'agrees' 'on' 'issuing' 'and' 'selling'"`
	FaceValue    Money    `parser:"'a' 'bond' 'of' @@"`
	Underwriter  string   `parser:"'to' @Ident"`
	IssuePrice   Money    `parser:"'for' @@ '.'"`
	MaturityDate *Date    `parser:"'The' 'aforementioned' 'bond' 'reaches' 'maturity' 'on' 'the' @@ '.'"`
	Coupons      *Coupons `parser:"('The' 'bond' 'pays' 'coupons' @@)?"`
}

type Contract

type Contract struct {
	Parties    []Party      `parser:"'The' 'parties' ':' @@ ';' 'and' (@@ ';' 'and')* @@ '.'"`
	Agreements []*Agreement `parser:"@@+"`
	Signatures []*Signature `parser:"@@+"`
}

Contract represents a contract with parties, agreements and a signature.

type Coupons

type Coupons struct {
	Rate  float64 `parser:"'with' 'an' 'interest' 'rate' 'of' (@Float | @Integer) '%'"`
	Dates []*Date `parser:"'paid' 'on' 'the' 'following' 'dates' ':' (@@ ',' | @@ | 'and' @@)+ '.'"`
}

type CurrencySwap

type CurrencySwap struct {
	EffectiveDate       *Date              `parser:"'The' 'parties' 'agree' 'on' 'a' 'currency' 'swap' 'transaction' 'effective' 'as' 'of' 'the' @@"`
	MaturityDate        *Date              `parser:"'and' 'termination' 'on' 'the' @@ '.'"`
	PayerA              string             `parser:"@Ident 'will' 'pay' 'a'"`
	PrincipalA          Money              `parser:"'principal' 'amount' 'of' @@ ','"`
	PayerB              string             `parser:"'and' 'the' @Ident 'will' 'pay' 'a'"`
	PrincipalB          Money              `parser:"'principal' 'amount' 'of' @@ '.'"`
	ImpliedExchangeRate ExchangeRate       `parser:""`
	EndExchangeRate     *ExchangeRate      `` /* 133-byte string literal not displayed */
	Interest            []*InterestPayment `parser:"@@*"`
}

type Date

type Date struct {
	Day   int    `parser:"@Integer"`
	Month string `parser:"('th' | 'rd' | 'st') 'of' @Ident"`
	Year  int    `parser:"@Integer"`
}

Date is a date in the format '1st of September 2022'. It marshals in JSON in the RFC3339 format.

type ExchangeRate

type ExchangeRate struct {
	BaseCurrency    string  `parser:"@Ident"`
	CounterCurrency string  `parser:"'/' @Ident"`
	Rate            float64 `parser:"@Float"`
}

type InterestPayment

type InterestPayment struct {
	Payer       string    `parser:"@Ident 'will' 'pay' 'a'"`
	FixedRate   float64   `parser:"( 'fixed' 'rate' 'interest' 'of' (@Float | @Integer) '%' "`
	InitialRate float64   `parser:"| 'floating' 'rate' 'interest' ',' 'initially' 'defined' 'as' (@Float | @Integer) '%' ',' ) "`
	Dates       []*Date   `parser:"'over' 'the' 'notational' 'amount' 'on' 'the' 'following' 'dates' ':' (@@ ',' | @@ | 'and' @@)+ '.'"`
	RateOption  LongIdent `parser:"('The' 'floating' 'rate' 'option' 'is' @(~'.')+ '.')?"`
}

type InterestRateSwap

type InterestRateSwap struct {
	NotationalAmount Money              `` /* 131-byte string literal not displayed */
	EffectiveDate    *Date              `parser:"'with' 'an' 'effective' 'date' 'as' 'of' 'the' @@"`
	MaturityDate     *Date              `parser:"'and' 'termination' 'on' 'the' @@ '.'"`
	Interest         []*InterestPayment `parser:"@@+"`
}

type LongIdent

type LongIdent string

LongIdent is an identifier that spans across multiple token yieldings.

func (*LongIdent) Capture

func (en *LongIdent) Capture(values []string) error

type Money

type Money struct {
	Currency string      `parser:"@Ident"`
	Amount   MoneyAmount `parser:"(@Money | @Float)"`
}

Money represents a monetary amount of a certain currency.

type MoneyAmount

type MoneyAmount float64

MoneyAmount is the the type of a monetary amount.

func (*MoneyAmount) Capture

func (b *MoneyAmount) Capture(values []string) error

type Party

type Party struct {
	Name       LongIdent `parser:"@(~',')+"`
	Identifier string    `parser:"',' 'undermentioned' 'as' @Ident"`
}

Party represents a party and its identifier.

type Signature

type Signature struct {
	Parties []string `parser:"'Signed' 'by'  @Ident (',' @Ident)* ('and' @Ident)*"`
	Date    *Date    `parser:"'on' 'the' @@ '.'"`
}

Signature represents a signature parsed from the format 'Signed by <Party>, [<Party>, ...] and <Party> on <Date>.'

The signature does not need the parties per se. They are only used to semantically validate the English text. The marshalled output is a Date object.

Jump to

Keyboard shortcuts

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