result

package
v0.0.0-...-0e8dd81 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HarvestElement

type HarvestElement struct {
	Metadata interface{} `json:"metadata"`          // Arbitrary document metadata
	Segment  string      `json:"segment,omitempty"` // Name of the segment this document belongs to

	Text string `json:"text"` // Text of this element

	MWSPaths   map[int64]map[string]MathFormula `json:"mws_id,omitempty"`  // information about each identifier within this document
	MWSNumbers []int64                          `json:"mws_ids,omitempty"` // list of identifiers within this document

	MathSource map[string]string `json:"math"` // Source of replaced math elements within this document
}

HarvestElement represents an <mws:data> harvest node, which can be contained both within ElasticSearch and MWS

func (*HarvestElement) UnmarshalXML

func (he *HarvestElement) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals xml into a harvest element

type HarvestSegment

type HarvestSegment struct {
	ID string `json:"segment"`

	Hash    string `json:"hash"`    // the hash of this segment (if any)
	Touched bool   `json:"touched"` // has this segment been touched within recent changes
}

HarvestSegment represents the name of the segment

type Hit

type Hit struct {
	ID string `json:"id,omitempty"` // the (possibly internal) id of this hit

	URL   string `json:"url,omitempty"` // the url of the document returned
	XPath string `json:"xpath"`         // the xpath of the query term to the formulae referred to by this id

	Element *HarvestElement `json:"source,omitempty"` // the raw harvest element (if any)

	Score float64 `json:"score,omitempty"` // score of this hit

	Snippets []string `json:"snippets,omitempty"` // extracts of this hit (if any)

	Math []*MathFormula `json:"math_ids"` // math found within this hit
}

Hit represents a single Hit

func (*Hit) PopulateMath

func (hit *Hit) PopulateMath() error

PopulateMath populates the 'Math' property of this hit using the 'math' property of the result

func (*Hit) PopulateMathSource

func (hit *Hit) PopulateMathSource() error

PopulateMathSource populates the maths sources for all mathFormulae within this hit

func (*Hit) PopulateSubsitutions

func (hit *Hit) PopulateSubsitutions(res *Result) error

PopulateSubsitutions populates the subsitutions field of all found math formulae in this hit

func (*Hit) UnmarshalElasticDocument

func (hit *Hit) UnmarshalElasticDocument(obj *elasticutils.Object) (err error)

UnmarshalElasticDocument unmarshals a document hit from elasticsearch If ids is non-nil use only ids for Math Elements

func (*Hit) UnmarshalElasticHighlight

func (hit *Hit) UnmarshalElasticHighlight(obj *elasticutils.Object) (err error)

UnmarshalElasticHighlight populates a document hit with a highlight hit

func (*Hit) UnmarshalJSON

func (hit *Hit) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals a json hit

type Kind

type Kind string

Kind represents the kind of result being returned

const (
	// EmptyKind is a ressult in response to the empty query
	EmptyKind Kind = ""
	// MathWebSearchKind is a result in represonse to a MathWebSearch query
	MathWebSearchKind Kind = "mwsd"
	// ElasticDocumentKind is a result returned from the document query
	ElasticDocumentKind Kind = "elastic-document"
	// ElasticKind is a result returned from the document + highlight query
	ElasticKind Kind = "elastic"
	// TemaSearchKind is a result returned from a combined elastic + MathWebSearch Query
	TemaSearchKind Kind = "tema"
)

type MathFormula

type MathFormula struct {
	Source string `json:"source,omitempty" xml:",chardata"` // MathML Element Representing entire formula

	DocumentURL string `json:"durl,omitempty"`          // document url (if any)
	LocalID     string `json:"url" xml:"local_id,attr"` // local formula id

	XPath   string `json:"xpath,omitempty"`   // XPath from the formula -> query
	SubTerm string `json:"subterm,omitempty"` // MathML Element representing matching subterm

	Substitution map[string]string `json:"subst,omitempty"` // MathML Elements representing values for the subsituted terms
}

MathFormula represents information about a single located math formula It supports JSON Marshal + Unmarshal (for reading it from mws results and sending it to the user) And XML Un-Marshelling (for reading it as part of raw harvest data)

func (*MathFormula) MathML

func (formula *MathFormula) MathML() (*utils.MathML, error)

MathML returns a MathML object representing this MathFormula

func (*MathFormula) PopulateSubsitutions

func (formula *MathFormula) PopulateSubsitutions(hit *Hit, res *Result) (err error)

PopulateSubsitutions populates the subsitutions field of this MathFormula, given a hit and a result

func (*MathFormula) RealMathID

func (formula *MathFormula) RealMathID() string

RealMathID returns the math id used for this object in dictionaries

func (*MathFormula) SetURL

func (formula *MathFormula) SetURL(url string)

SetURL sets the url of a MathInfo object

type QueryVariable

type QueryVariable struct {
	Name  string `json:"name"`  // name of the variable
	XPath string `json:"xpath"` // xpath of the variable relative to the root
}

QueryVariable represents a query variable

type Result

type Result struct {
	Kind Kind `json:"kind"` // the kind of query this is a result to

	Took           *time.Duration            `json:"took,omitempty"`  // how long the overall query took
	TookComponents map[string]*time.Duration `json:"stats,omitempty"` // how long each of the components took

	Total int64 `json:"total"` // the total number of results
	From  int64 `json:"from"`  // result number this page starts at
	Size  int64 `json:"size"`  // number of results returned

	Variables []*QueryVariable `json:"qvars,omitempty"` // the list of

	HitIDs []int64 `json:"ids,omitempty"`  // the ids of the hits
	Hits   []*Hit  `json:"hits,omitempty"` // the current page of hits
}

Result represents a Query Result which can be from either MathWebSearch, ElasticSearch or a combined TemaSearch Result too unmarshal

func (*Result) Normalize

func (res *Result) Normalize()

Normalize normalizes a result so that it can be used reproducibly in tests

func (*Result) PopulateSubsitutions

func (res *Result) PopulateSubsitutions() error

PopulateSubsitutions populates all substiutions within all hits of this result

func (*Result) UnmarshalElastic

func (res *Result) UnmarshalElastic(page *elasticutils.ResultsPage) error

UnmarshalElastic un-marshals a response from elastic

func (*Result) UnmarshalMWS

func (res *Result) UnmarshalMWS(response *http.Response) error

UnmarshalMWS un-marshals a resoponse from mws

Jump to

Keyboard shortcuts

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