mesh

package
v0.0.0-...-16c3dd7 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnimalCodes = map[string]string{
	"C22": "Animal Diseases",
}

AnimalCodes list codes for animal categories

View Source
var Categories = map[string]string{
	"A": "Anatomy",
	"B": "Organisms",
	"C": "Diseases",
	"D": "Chemicals and Drugs",
	"E": "Analytical, Diagnostic and Therapeutic Techniques and Equipment",
	"F": "Psychiatry and Psychology",
	"G": "Biological Sciences",
	"H": "Physical Sciences",
	"I": "Anthropology, Education, Sociology and Social Phenomena",
	"J": "Technology and Food and Beverages",
	"K": "Humanities",
	"L": "Information Science",
	"M": "Persons",
	"N": "Health Care",
	"V": "Publication Characteristics",
	"Z": "Geographic Locations",
}

Categories lists the top-level categories in the MeSH descriptor hierarchy.

View Source
var ClinicalCategories = map[string]string{
	"A": "Anatomy",
	"B": "Organisms",
	"C": "Diseases",
	"D": "Chemicals and Drugs",
	"E": "Analytical, Diagnostic and Therapeutic Techniques and Equipment",
	"F": "Psychiatry and Psychology",
	"G": "Biological Sciences",
	"M": "Persons",
	"V": "Publication Characteristics",
}

ClinicalCategories lists the top-level clinical categories in the MeSH descriptor hierarchy.

View Source
var Normalize taxonomy.Normalizer = func(str string) (string, string) {
	s := strings.ToLower(str)
	s = reEG.ReplaceAllString(s, "")
	s = reE.ReplaceAllString(s, "")
	s = strings.Replace(s, ",", " ", -1)
	s = strings.Replace(s, "b hbsag", "hbv surface antigen", -1)
	s = strings.Replace(s, "hbsag hbv", "hbv surface antigen", -1)
	s = strings.Replace(s, "her2", "her-2", -1)

	s = reCNS.ReplaceAllString(s, "central nervous system")
	s = reAML.ReplaceAllString(s, "acute myeloid leukemia")
	s = reNSCLC.ReplaceAllString(s, "non-small cell lung cancer")
	s = reCLL.ReplaceAllString(s, "chronic lymphocytic leukemia")
	s = reHCC.ReplaceAllString(s, "hepatocellular carcinoma")
	s = reMM.ReplaceAllString(s, "multiple myeloma")
	s = reGI.ReplaceAllString(s, "gastrointestinal")
	s = reMRI.ReplaceAllString(s, "magnetic resonance imaging")

	if strings.Contains(s, "diabetes") {
		s = re1.ReplaceAllString(s, "1")
		s = re2.ReplaceAllString(s, "2")
	}

	if strings.Contains(s, "hepatitis") {
		s = strings.Replace(s, "b hbv", "b", -1)
		s = strings.Replace(s, "c hcv", "c", -1)
		s = strings.Replace(s, "active ", "", -1)
		s = strings.Replace(s, " treatment", "", -1)
	} else {
		s = reHBV.ReplaceAllString(s, "b hepatitis")
		s = reHCV.ReplaceAllString(s, "c hepatitis")
		s = strings.Replace(s, "b c hep", "b c hepatitis", -1)
	}
	if len(s) == 0 {
		s = str
	}
	s = strings.Trim(s, " /.,;:-")
	normalizedTerm := text.NormalizeWhitespace(s)

	normalizedMatch := reParenthesis.ReplaceAllString(normalizedTerm, " ")
	normalizedMatch = rePunct.ReplaceAllString(normalizedMatch, " ")
	normalizedMatch = strings.TrimSpace(normalizedMatch)

	l := strings.Fields(normalizedMatch)
	l = filter(l, generalWords)
	if v := strings.Join(l, " "); len(v) > 0 {
		normalizedTerm = v
	}

	l = filter(l, labelWords)
	sort.Strings(l)
	l = slice.Dedupe(l)
	normalizedMatch = strings.Join(l, " ")
	if len(normalizedMatch) == 0 {
		normalizedMatch = normalizedTerm
	}
	return normalizedMatch, normalizedTerm
}

Normalize defines a normalizer function for MeSH terms. normalizedTerm replaces the extracted NER term. normalizedMatch is used to match terms to concepts.

Functions

func GetCategories

func GetCategories(tns []string) set.Set

GetCategories gets the categories from tree numbers.

func GetTopCode

func GetTopCode(tn string) string

GetTopCode gets the top code from a tree number.

func GetTopCodes

func GetTopCodes(tns []string) set.Set

GetTopCodes gets the top codes from tree numbers.

func HasAnimalCode

func HasAnimalCode(tns []string) bool

HasAnimalCode returns true if any of the top codes are for animals.

func HasClinicalCategory

func HasClinicalCategory(tns []string) bool

HasClinicalCategory returns true if any of the categories are clinical.

func Load

func Load(xmlFname string, customFnames ...string) *taxonomy.Taxonomy

Load loads a MeSH taxonomy from files.

func Trim

func Trim(tns []string) []string

Trim removes non-clinical codes.

Types

type Concept

type Concept struct {
	XMLName xml.Name    `xml:"Concept"`
	Name    ConceptName `xml:"ConceptName"`
	Terms   Terms       `xml:"TermList"`
}

Concept defines the xml struct for Concept.

type ConceptName

type ConceptName struct {
	XMLName xml.Name `xml:"ConceptName"`
	Value   string   `xml:"String"`
}

ConceptName defines the xml struct for ConceptName.

type Concepts

type Concepts struct {
	XMLName  xml.Name  `xml:"ConceptList"`
	Concepts []Concept `xml:"Concept"`
}

Concepts defines the xml struct for Concepts.

type Descriptor

type Descriptor struct {
	XMLName     xml.Name       `xml:"DescriptorRecord"`
	Name        DescriptorName `xml:"DescriptorName"`
	Concepts    Concepts       `xml:"ConceptList"`
	TreeNumbers TreeNumbers    `xml:"TreeNumberList"`
}

Descriptor defines the xml struct for Descriptor.

type DescriptorName

type DescriptorName struct {
	XMLName xml.Name `xml:"DescriptorName"`
	Value   string   `xml:"String"`
}

DescriptorName defines the xml struct for DescriptorName.

type Descriptors

type Descriptors struct {
	XMLName     xml.Name     `xml:"DescriptorRecordSet"`
	Descriptors []Descriptor `xml:"DescriptorRecord"`
}

Descriptors defines the xml struct for Descriptors.

type Term

type Term struct {
	XMLName   xml.Name `xml:"Term"`
	Preferred string   `xml:"ConceptPreferredTermYN,attr"`
	Name      string   `xml:"String"`
	ID        string   `xml:"TermUI"`
}

Term defines the xml struct for Term.

func (Term) IsPreferred

func (t Term) IsPreferred() bool

IsPreferred indicates whether the term is a preferred term for a concept.

type Terms

type Terms struct {
	XMLName xml.Name `xml:"TermList"`
	Terms   []Term   `xml:"Term"`
}

Terms defines the xml struct for Terms.

type TreeNumbers

type TreeNumbers struct {
	XMLName     xml.Name `xml:"TreeNumberList"`
	TreeNumbers []string `xml:"TreeNumber"`
}

TreeNumbers defines the xml struct for TreeNumbers.

Jump to

Keyboard shortcuts

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