best_effort_parser 0.3.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 49

best_effort_parser #

Author: Jack Warren

Build Status Coverage Status Pub

Provides assistance with parsing arbitrary, unstructured user input into output types of your choice.

Name Parsing #

best_effort_parser/name.dart

Provides parsing of names by categorizing different parts:

  • family: A person's last name(s)
  • given: A person's first and middle name(s)
  • dropping particle: particle(s) before the person's last name that are ignored if only the last name is shown
  • non-dropping particle: particles(s) before the person's last name that are not ignored if only the last name is shown
  • suffix: abbreviations after a person's last name

Features handling of a wide range of formats: beyond just "<first> <last>" and "<last>, <first>", particles and suffixes are parsed from any reasonably correct position a user may place them.

Example: #

name_example.dart

import 'package:best_effort_parser/name.dart';

void main(List<String> arguments) =>
    print(NameParser.basic().parse(arguments.join(' ')).diagnosticString());

Demo:

λ  dart name_example.dart 'Jack Warren'
[Given]: Jack [Family]: Warren

λ  dart name_example.dart 'La Fontaine, Jean de'
[Given]: Jean [Dropping Particle]: de [Non-dropping Particle]: La [Family]: Fontaine

λ  dart name_example.dart 'Gates, Bill III'
[Given]: Bill [Family]: Gates [Suffix]: III

λ  dart name_example.dart 'Willem de Kooning'
[Given]: Willem [Dropping Particle]: de [Family]: Kooning

Customization of both parsing and output type is available.

Date Parsing #

best_effort_parser/date.dart

Provides parsing of dates by collecting years, months, and days and assembling those parts into a list. Each entry in that output list represents a singular date, so a string containing multiple dates or a range will have multiple entries in its output.

Example: #

date_example.dart

import 'package:best_effort_parser/date.dart';

void main(List<String> arguments) => 
    DateParser.basic().parse(arguments.join(' ')).forEach(print);

Demo:

λ  dart date_example.dart 'January 1st, 2019'
[Day]: 1 [Month]: 1 [Year]: 2019

λ  dart date_example.dart '1/2/3'
[Day]: 2 [Month]: 1 [Year]: 2003

λ  dart date_example.dart '10/10/90 - 3/13/18'
[Day]: 10 [Month]: 10 [Year]: 1990
[Day]: 13 [Month]: 3 [Year]: 2018

λ  dart date_example.dart 'Spring-Summer 2010'
[Month]: 3 [Year]: 2010
[Month]: 6 [Year]: 2010

λ  dart date_example.dart '1999-15-6'
[Day]: 6 [Month]: 3 [Year]: 1999

Customization of both parsing and output type is available.

Feature requests and bugs #

Please file feature requests and bugs at the issue tracker.

0.3.1 #

  • Standardize formatting and documentation

0.3.0 #

  • Add date parsing

0.2.8 #

  • Make the deployment script executable

0.2.7 #

  • Manual Travis deployment because "deploy:" doesn't appear to work

0.2.6 #

  • Skip cleanup

0.2.5 #

  • Yet more Travis fixes

0.2.4 #

  • More Travis fixes

0.2.3 #

  • Configure deployment script deploy.sh

0.2.2 #

  • Configure Travis and Coveralls

0.2.1 #

  • Updated README.md
  • Name parsing example (name_example.dart)

0.2.0 #

  • Name parsing with documentation, testing, and diagnostics

0.1.0 #

  • Name parsing functional
    • TODO: better documentation, testing, diagnostics

0.0.1 #

  • Add project configuration files
  • Initial version, created by Stagehand

example/README.md

Examples #

Sample behavior of these examples is available in the top-level README.md file

name_example.dart #

A command-line utility demoing the capabilities of package:best_effort_parser/name.dart.

import 'package:best_effort_parser/name.dart';

/// Bare-bones example of using [NameParser] as a command-line program. All arguments are
/// concatenated with spaces and then run through the parser with default settings.
///
/// Example usage:
/// ```text
/// λ  dart name_example.dart 'Jack Warren'
/// [Given]: Jack [Family]: Warren
/// ```
void main(List<String> arguments) =>
    print(NameParser.basic().parse(arguments.join(' ')).diagnosticString());

Provided dart is on your path, the script may be run from the example/ directory with dart name_exaple.dart followed by strings of your choice.

date_example.dart #

A command-line utility demoing the capabilities of package:best_effort_parser/date.dart.

import 'package:best_effort_parser/date.dart';

/// Bare-bones example of using [DateParser] as a command-line program. All arguments are
/// concatenated with spaces and then run through the parser with default settings.
///
/// Example usage:
/// ```text
/// λ  dart date_example.dart 'January 1st, 2019'
/// [Day]: 1 [Month]: 1 [Year]: 2019
/// ```
void main(List<String> arguments) =>
    DateParser.basic().parse(arguments.join(' ')).forEach(print);

Provided dart is on your path, the script may be run from the example/ directory with dart date_example.dart followed by strings of your choice.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  best_effort_parser: ^0.3.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:best_effort_parser/date.dart';
import 'package:best_effort_parser/name.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
93
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

We analyzed this package on Jun 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1

Maintenance suggestions

Package is getting outdated. (-7.40 points)

The package was last published 56 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
Dev dependencies
pedantic ^1.0.0
test ^1.0.0
test_coverage ^0.2.0