1.0.1 • Published 8 months ago

websoc-fuzzy-search v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

websoc-fuzzy-search

A fuzzy search module for various course (including department, GE category) and instructor data from UCI.

The module name is a misnomer, since we don't get our data from WebSoc at all (but rather from the Catalogue), but it's stuck.

Installation

npm install --save websoc-fuzzy-search

or

yarn add websoc-fuzzy-search

or

pnpm install websoc-fuzzy-search

Documentation

Types

CourseLevel

CourseLevel is an integer literal that holds one of the following values.

Literal ValueMeaning
0Lower Division courses (1-99)
1Upper Division courses (100-199)
2Graduate/Professional Only courses (200+)

GECategory

GECategory is a string literal that holds one of the following values.

Literal ValueMeaning
GE-1ALower Division Writing
GE-1BUpper Division Writing
GE-2Science and Technology
GE-3Social and Behavioral Sciences
GE-4Arts and Humanities
GE-5AQuantitative Literacy
GE-5BFormal Reasoning
GE-6Language other than English
GE-7Multicultural Studies
GE-8International/Global Issues

ResultType

ResultType is a string literal that holds one of the following values. The internal value is used to sort the final response.

Literal ValueInternal Value
GE_CATEGORY4
DEPARTMENT3
COURSE2
INSTRUCTOR1

FilterOptions

FilterOptions represents any desired Metadata attributes in the final result(s). It has four possible fields, all of which are optional.

A list of acceptable values for departments and schools can be found in the source data here.

FieldTypeDescription
courseLevelCourseLevel[]The course level(s) to match. (Courses only)
geListGECategory[]The GE categor(y/ies) to match. (Courses only)
departmentstring[]The department(s) to match. (Courses and Instructors)
schoolstring[]The school(s) to match. (Courses and Instructors)

SearchParams

SearchParams represents the parameters for which to search. It has four possible fields, all of which are optional.

FieldTypeDescription
querystringThe search query.
numResultsnumberThe maximum number of results to return.
resultTypeResultTypeWhich type of result to return exclusively.
filterOptionsFilterOptionsAny Metadata attributes the result(s) must possess.

SearchResult

SearchResult represents a single object matched by the fuzzy search process.

FieldTypeDescription
typeResultTypeThe type of the result matched.
namestringThe descriptive name of the result matched.
metadataanyAny metadata relevant to the result matched. (Optional)

Two interfaces extend upon this interface; each has a different type for the metadata field and its own type guard function for TypeScript compatibility.

CourseMetadata

FieldTypeDescription
departmentstringThe department that offers this course.
numberstringThe course number.
geListGECategory[]GE categor(y/ies), if any, this course satisfies.
courseLevelCourseLevelThe level of this course.
schoolstringThe school/academic unit this course falls under.

InstructorMetadata

FieldTypeDescription
ucinetidstringThe instructor's UCINetID.
schoolstring[]The school(s) to which this instructor belong(s).
departmentstring[]The department to which this instructor belongs.

Functions

search

Signature: search(params?: SearchParams): Record<string, SearchResult>

Performs a fuzzy-search query based on the parameters given (if any), and returns a mapping of unique string identifiers to SearchResult objects.

isCourseSearchResult and isInstructorSearchResult

These type guard functions are provided for TypeScript-based projects and are fairly self-explanatory.

1.0.1

8 months ago

1.0.0

8 months ago

0.10.0

2 years ago

0.9.0

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.0-rc.1

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.6.3

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago