npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

db-clean-station-name

v1.2.0

Published

Remove noise and fix common typographic errors in Deutsche Bahn (DB, german railways) and VBB (Berlin-Brandenburg transportation authority) station names.

Downloads

55

Readme

db-clean-station-name

Remove noise and common typographic issues from Deutsche Bahn (DB, german railways) and VBB (Berlin-Brandenburg transportation authority) station names, returned e.g. by the db-hafas and vbb-hafas module. For a list of changes that are applied to names, see the rules section.

npm version Build Status Greenkeeper badge license chat on gitter

Installation

npm install db-clean-station-name

Usage

const cleanStationName = require('db-clean-station-name')

const noisy = 'S+U Berlin Yorckstr. S2 U7 (S+U)'
const cleaned = cleanStationName(noisy)
console.log(cleaned) // 'Berlin Yorckstraße'

Rules

The module applies a specific set of rules, which were test-run against a dataset of ≈250,000 station names. The matches column in the following table specifies how many of those station names a rule could be applied to at least once. Samples for each rule were checked manually for QA.

Rule | Example | Matches -----|---------|-------- Fix typographically incorrect apostrophes | Up`n KiwittUp’n Kiwitt | ≈100 Replace non-round braces | Bersarinplatz [Weidenweg]Bersarinplatz (Weidenweg) | ≈100 Fix whitespace for braces | Frankfurt(Main)HbfFrankfurt (Main) Hbf | ≈2100 Fix whitespace for punctuation and slashes | St.GeorgSt. Georg, Landau a.d. IsarLandau a.d. Isar | ≈700 Replace generic abbreviations: Abzw., b., Ri. | Abzw. BaalbornAbzweig Baalborn, Garching b. MünchenGarching bei München | ≈10000 Replace most common location abbreviations: Thür, Württ, Meckl, … Note that this rule will probably be replaced by a more generic location-parsing rule at some point | Minden(Westf)Minden (Westfalen) | ≈5000 Replace Str. with Straße | Bülowstr.Bülowstraße, Willy-Brandt-Str.Willy-Brandt-Straße | ≈22000 Remove defined set of line and product names: U1, (U), (Bus), (S 1), S+U, … | Alexanderplatz (U) U5 U8, BerlinAlexanderplatz, Berlin, Budberg (B63), WerlBudberg (B63), Werl | ≈700

There are some additional rules which aren't listed here, but those only affect a handful of stations or fix the result of other rules (e.g. removing duplicate whitespace).

Removing location names

This module also offers a method to attempt to remove location names from station names, e.g. the Berlin in Amrumer Straße, Berlin or Köln in Köln Messe/Deutz. The module also has a blacklist for particles for which the location is never removed even if it was detected correctly, e.g. for Frankfurt Süd, where the remaining part wouldn't really make sense on its own.

const cleanStationNameWithLocation = require('db-clean-station-name/lib/with-location')

// you must provide a station name as well as a geolocation for that station
const cleaned = cleanStationNameWithLocation('(S) Berlin Hauptbahnhof', { longitude: 13.0991973, latitude: 52.404288 })
const result = {
    full: 'Berlin Hauptbahnhof' // normal output of db-clean-station-name
    short: 'Hauptbahnhof' // will be `null` if no locations were detected
    matchedLocationIds: ['11000000'] // some id(s) corresponding to locations that were detected, you can use those to check e.g. if two stations are in the same city. will be empty of no location(s) were detected. note that for cases like `Frankfurt Süd`, where `short` will be null because nothing could be removed because of some blacklisted name, the list of matched location ids can still contain values
}

Contributing

If you found a bug or want to propose a feature, feel free to visit the issues page.