glossary

package
v0.0.0-...-05931ac Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

README

Glossary Module

The Glossary Module is responsible for mapping the property URLs with their labels and descriptions for each corresponding language.

It works by generating it's own mapping structure from a dataset that only contains properties. That structure is stored and can later be re-used when the recommender is serving.

It also contains utilities for filtering lists of properties by certain glossary values.

Properties that are used

Labels and descriptions are just a type of property that has special handling by wikidata. They are used in the same way for both the Items and Properties.

  • Labels:
    • <http://schema.org/name> (used by glossary)
    • <http://www.w3.org/2000/01/rdf-schema#label>
    • <http://www.w3.org/2004/02/skos/core#prefLabel>
    • <http://www.w3.org/2004/02/skos/core#altLabel> (alternative name)
  • Descriptions:
    • <http://schema.org/description> (used by glossary)

Each value is given in the form of "text"@language. One example for Belgium in british english is: "Belgium"@en-gb

Notes about Glossary usage

The Glossary is typically only used for properties only, but nothing prevents you from generating a glossary for items as well, though this will not be used by the server.

TODO

  • Glossary is using hard-coded properties, but they should ideally come from a configuration file that is specific to wikidata.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildGlossary

func BuildGlossary(filePath string) (*Glossary, GlossaryStats, error)

BuildGlossary from a dataset of N-Triples todo: Should this method receive the filepath, a filehandler, or a tripleparser?

Types

type Content

type Content struct {
	Label       string
	Description string
}

Content of each glossary entry. Identifiers are usually supplied in the map.

type Glossary

type Glossary map[Key]*Content // glossary[property,language]

Glossary holds an entire glossary.

func ReadFromFile

func ReadFromFile(path string) (*Glossary, error)

ReadFromFile reads a binary file and de-serializes it into a glossary.

func (*Glossary) OutputStats

func (glos *Glossary) OutputStats()

OutputStats of the glossary to stdout.

func (*Glossary) WriteToFile

func (glos *Glossary) WriteToFile(path string)

WriteToFile will serialize the glossary into a binary file.

type GlossaryStats

type GlossaryStats struct {
	TotalPropertyCount    uint64
	TotalLabelCount       uint64
	TotalDescriptionCount uint64
	PropertiesPerLanguage map[string]uint64
}

type Key

type Key struct {
	Property string
	Lang     string
}

Key of each glossary entry.

type LabeledRecommendation

type LabeledRecommendation struct {
	Property    *schematree.IItem
	Content     *Content
	Probability float64
}

LabeledRecommendation are recommendations with glossary information attached

func TranslateRecommendations

func TranslateRecommendations(glossary *Glossary, language string, recommendations schematree.PropertyRecommendations) []LabeledRecommendation

TranslateRecommendations adds glossary information to recommendations from the schematree

Jump to

Keyboard shortcuts

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