Skip to content

Instantly share code, notes, and snippets.

View gpeterso's full-sized avatar

Jeff Peterson gpeterso

View GitHub Profile
@gpeterso
gpeterso / KStemTest.java
Last active January 19, 2023 23:06
Just a test to reproduce a stemming problem from a bug report... The query "homer historicity" returned results for the stemmed tokens "home" and "historic", which was not at all what the user was looking for. It looks like Lucene's KStemer implementation does have exceptions for proper nouns, but it just so happens that "homer" is not among them.
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.en.KStemFilter;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.util.*;
import java.io.StringReader;
public class KStemTest {
public static final String QUERY_TERMS = "homer historicity";
#!/usr/bin/env python3
# prints a tab-delimited list of Alma location codes & names
import requests
import sys
import os
from collections import namedtuple
from typing import Iterable
key = os.environ.get('ALMA_API_KEY') or \
/**
* An example of dynamically appending a template to a "grandparent" element.
* It's usually not a good practice for a component to perform DOM manipulation
* on outside elements, but in Primo it can sometimes be useful when your target
* element doesn't have an "after" hook.
*/
class MyCustomComponentController {
constructor($scope, $compile, $element) {
this.$scope = $scope;
this.$element = $element;
@gpeterso
gpeterso / browzine.component.js
Last active July 12, 2021 14:37
Third Iron's instructions for implementing the BrowzZne plugin makes it hard to have multiple `prmSearchResultAvailabilityLineAfter` components. This is an example of how you might wrap the BrowZine integration into its own component, which then allows you to add multiple components to the `prmSearchResultAvailabilityLineAfter` template.
class BrowzineController {
constructor(browzineService, $scope) {
this.browzineService = browzineService;
this.$scope = $scope;
}
$onInit() {
this.browzineService.handleSearchResult(this.$scope);
}
}
@gpeterso
gpeterso / primo_ga_example.js
Created August 9, 2019 16:44
Tracking Primo pageviews in Google Analytics
const gaTrackingId = '...';
class GoogleAnalytics {
constructor($rootScope, $location, $window) {
this.$rootScope = $rootScope;
this.$location = $location;
this.$window = $window;
this.loadAnalytics(this.$window);
}