wikipedia

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FORMAT_WIKI = TextFormat("wiki")
	FORMAT_TEXT = TextFormat("plain")
	FORMAT_RAW  = TextFormat("raw")
)
View Source
const (
	// Ranking based on the number of incoming links, some templates, page language and recency (templates/language/recency may not be activated on this wiki).
	RankingClassic = SearchRanking("classic")

	// Ranking based on some templates, page language and recency when activated on this wiki.
	RankingClassicNoBoost = SearchRanking("classic_noboostlinks")

	// Ranking based solely on query dependent features (for debug only).
	RankingEmpty = SearchRanking("empty")

	// Weighted sum based on incoming links
	RankingIncomingLinks = SearchRanking("wsum_inclinks")

	//Weighted sum based on incoming links and weekly pageviews
	RankingIncomingLinksWeeklyViews = SearchRanking("wsum_inclinks_pv")
)
View Source
const (
	SearchTypeText      = SearchType("text")      // Search the text of pages.
	SearchTypeTitle     = SearchType("title")     // Search only page titles.
	SearchTypeNearMatch = SearchType("nearmatch") // Search only page titles that begin with the search term.
)
View Source
const EN = "en"

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Config

type Config struct {
	http.Stack
}

type Extracts

type Extracts struct {
	Lang       string     `wiki:"-"`
	ID         ID         `wiki:"id"`
	TextOnly   bool       `wiki:"explaintext"`
	TextFormat TextFormat `wiki:"exsectionformat"`
	Chars      int        `wiki:"exchars"`     // How many characters to return. Actual text returned might be slightly longer.
	Sentences  int        `wiki:"exsentences"` // How many sentences to return.
	OnlyIntro  bool       `wiki:"exintro"`     // Return only content before the first section
	// contains filtered or unexported fields
}

The request type for wikipedia extracts module https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bextracts

type ID

type ID = gold.IRI[Wikipedia]
type Search struct {
	Lang    string        `wiki:"-"`
	Type    SearchType    `wiki:"srwhat"`      // The type of search to perform.
	Query   string        `wiki:"srsearch"`    // The search query string.
	Limit   int           `wiki:"srlimit"`     // The maximum number of search results to return.
	Offset  int           `wiki:"sroffset"`    // The offset for the search results.
	Ranking SearchRanking `wiki:"srqiprofile"` // The ranking method to use.
	// contains filtered or unexported fields
}

The request type for wikipedia query search module https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bsearch

type SearchRanking

type SearchRanking string

Ranking methods for wikipedia search

type SearchType

type SearchType string

Type of search to perform

type TextFormat

type TextFormat string

type Wikipedia

type Wikipedia struct {
	http.Stack
	// contains filtered or unexported fields
}

Wikipedia HTTP client

func New

func New(cfg Config) (*Wikipedia, error)

Creates new instance of HTTP client

func (*Wikipedia) Extracts

func (api *Wikipedia) Extracts(ctx context.Context, req Extracts) (string, string, error)

Extracts wikipedia article content https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bimageinfo

func (*Wikipedia) Search

func (api *Wikipedia) Search(ctx context.Context, req Search) ([]websearch.Fact, error)

Extracts wikipedia article content https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bimageinfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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