Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A python wrapper for FMR

Project description

pyfmr: a python wrapper for FMR



Install pyfmr via pip

pip install pyfmr

Grammar file

Save the following grammar content to file sf.grammar

<flight> = <departure> <arrival> {nf.flight($1, $2)};
[flight] = <arrival> <departure> {nf.flight($2, $1)};

<departure> = <from> <city> {nf.I($2)};

<arrival> = <to> <city> {nf.I($2)};
[arrival] = <arrival> {nf.arrival($1)};

<from> = "从" ;

<to> = "到" | "去" | "飞";

<city> = "北京"       {nf.I($@)}
       | "天津"       {nf.I($@)}
       | "上海"       {nf.I($@)}
       | "重庆"       {nf.I($@)}
       | `.(?:城|都)` {nf.I($@)}

<city_ext> = <city>            {nf.I($1)}
           | (any{1,1}) <city> {nf.I($2)}

<cities> = "直辖市:" (list<city_ext>) {nf.I($@)};

Python example codes

import pyfmr

p = pyfmr.Parser("./sf.grammar")
strs = [
for l in strs:
    ret = p.extract(l, "cities")
    for item in ret:

How to build

The cross compiling is done by xgo.


  • Docker
  • Golang


# 1. clone the git repo
git clone && cd pyfmr

# 2. pull xgo docker image
docker pull karalabe/xgo-latest

# 3. install xgo
go get

# 4. build shared libraries
xgo --targets=*/amd64 -buildmode=c-shared -out pyfmr/lib/fmr

# 5. build wheel
python3 sdist bdist_wheel

# 6. upload to
python3 -m twine upload dist/*

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyfmr, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size pyfmr-0.0.2-py3-none-any.whl (16.6 MB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pyfmr-0.0.2.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page