From 72d6fc9cdd39907a01890a9091b39157a1ebbf11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay-Michael=20W=C3=BCrzner?= Date: Thu, 9 Nov 2017 15:11:36 +0100 Subject: [PATCH 1/7] * working transcription per GET --- .gitignore | 2 ++ gramophone/apps/gp_app.py | 28 ++++++++++++++++++++++--- gramophone/scripts/gramophone.py | 2 +- gramophone/scripts/gramophone_server.py | 27 ++++++++++++++++++++++-- setup.py | 2 +- 5 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fcaef17 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# vim swap files +*.swp diff --git a/gramophone/apps/gp_app.py b/gramophone/apps/gp_app.py index e362d43..0f57cfd 100644 --- a/gramophone/apps/gp_app.py +++ b/gramophone/apps/gp_app.py @@ -1,12 +1,34 @@ from __future__ import absolute_import from flask import Flask +from flask import request -def create_gp_app(mapping): +def create_gp_app(aligner,transcriber,rater): app = Flask(__name__) - @app.route('/gp') + @app.route('/gp/', methods=['GET', 'POST']) def index(): - return mapping + if request.method == 'GET': + + results = [] + strings = request.args.getlist('w') + for string in strings: + segmentations = aligner.scan(string.lower()) + best_transcription = [] + best_prob = 0.0 + for segmentation in segmentations: + transcriptions = transcriber.transcribe(segmentation) + for transcription in transcriptions: + prob = rater.rate([segmentation,transcription]) + #click.echo("%s: %f" % (u",".join(transcription),prob), err=True) + if prob >= best_prob: + best_prob = prob + best_transcription = transcription + results.append(u",".join(best_transcription)) + + return str(results) + + elif request.method == 'POST': + return str(request.form) return app diff --git a/gramophone/scripts/gramophone.py b/gramophone/scripts/gramophone.py index 9225753..88721bc 100644 --- a/gramophone/scripts/gramophone.py +++ b/gramophone/scripts/gramophone.py @@ -117,7 +117,7 @@ def apply(mapping,crf,lm,strings): # convert for string in in_strings: - segmentations = aligner.scan(string) + segmentations = aligner.scan(string.lower()) best_transcription = [] best_prob = 0.0 for segmentation in segmentations: diff --git a/gramophone/scripts/gramophone_server.py b/gramophone/scripts/gramophone_server.py index b83047a..1157b6e 100644 --- a/gramophone/scripts/gramophone_server.py +++ b/gramophone/scripts/gramophone_server.py @@ -3,12 +3,35 @@ import click from gramophone import apps +from gramophone import gp @click.command() @click.option('-M', '--mapping', required=True, help='grapheme-phoneme mapping') -def run(mapping): +@click.option('-c', '--crf', required=True, help='transcription CRF model') +@click.option('-l', '--language-model', 'lm', required=True, help='rating language model') +def run(mapping,crf,lm): """ Run the application """ - app = apps.create_gp_app(mapping) + + # + # loading + # + click.echo(u"Loading...", err=True) + + click.echo(u"...data alignment", err=True) + aligner = gp.Aligner(mapping=mapping) + + click.echo(u"...transcription CRF model", err=True) + transcriber = gp.Transcriber() + transcriber.load(crf) + + click.echo(u"...n-gram language model", err=True) + rater = gp.Rater.load(lm) + + + # + # load app and run + # + app = apps.create_gp_app(aligner,transcriber,rater) app.run() diff --git a/setup.py b/setup.py index 608033e..52096a1 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ entry_points={ 'console_scripts': [ 'gramophone=gramophone.scripts.gramophone:cli', - 'gramophone_server=gramophone.scripts.gramophone_server:run', + 'gramophone-server=gramophone.scripts.gramophone_server:run', ] }, ) From 39713291320cacd7f620c1068eee448e5a97716b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay-Michael=20W=C3=BCrzner?= Date: Wed, 15 Nov 2017 17:06:50 +0100 Subject: [PATCH 2/7] result formatting --- .gitignore | 2 ++ gramophone/apps/gp_app.py | 15 ++++++++++---- gramophone/gp/__init__.py | 1 + gramophone/gp/alignment.py | 10 +++++++--- gramophone/gp/formatting.py | 26 +++++++++++++++++++++++++ gramophone/scripts/gramophone_server.py | 6 +++++- 6 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 gramophone/gp/formatting.py diff --git a/.gitignore b/.gitignore index fcaef17..33bc246 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # vim swap files *.swp +# pyc files +*.pyc diff --git a/gramophone/apps/gp_app.py b/gramophone/apps/gp_app.py index 0f57cfd..0856426 100644 --- a/gramophone/apps/gp_app.py +++ b/gramophone/apps/gp_app.py @@ -3,15 +3,22 @@ from flask import Flask from flask import request -def create_gp_app(aligner,transcriber,rater): +def create_gp_app(aligner,transcriber,rater,formatter): app = Flask(__name__) @app.route('/gp/', methods=['GET', 'POST']) def index(): if request.method == 'GET': - results = [] + # get args strings = request.args.getlist('w') + formats = request.args.getlist('f') + + oformat = "" + if formats: + oformat = formats[0] + + results = [] for string in strings: segmentations = aligner.scan(string.lower()) best_transcription = [] @@ -24,9 +31,9 @@ def index(): if prob >= best_prob: best_prob = prob best_transcription = transcription - results.append(u",".join(best_transcription)) + results.append((string,u",".join(best_transcription),prob)) - return str(results) + return formatter.encode(results,oformat) elif request.method == 'POST': return str(request.form) diff --git a/gramophone/gp/__init__.py b/gramophone/gp/__init__.py index 24c99dc..45d21ef 100644 --- a/gramophone/gp/__init__.py +++ b/gramophone/gp/__init__.py @@ -1,3 +1,4 @@ from .alignment import Aligner from .transcription import Transcriber from .rating import Rater +from .formatting import Formatter diff --git a/gramophone/gp/alignment.py b/gramophone/gp/alignment.py index 96a6451..91fb08b 100644 --- a/gramophone/gp/alignment.py +++ b/gramophone/gp/alignment.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import sys import pywrapfst as fst import regex as re @@ -41,9 +40,15 @@ def chain(self,g): t.set_output_symbols(self.syms) src = t.add_state() t.set_start(src) + dest = src for c in g: + # skip unknown symbols + try: + s = self.syms.find(c) + except: + continue dest = t.add_state() - t.add_arc(src,fst.Arc(self.syms.find(c), self.syms.find(c), "0", dest)) + t.add_arc(src,fst.Arc(s, s, "0", dest)) src = dest t.set_final(dest) return t @@ -89,7 +94,6 @@ def __align_fst(self,g,p): t4.project(project_output=True) if t4.num_arcs(t4.start()) == 0: - sys.stderr.write(u"Empty expansion: %s %s\n" % (g, p)) return fst.Fst() t5 = fst.compose(t3,self.E) diff --git a/gramophone/gp/formatting.py b/gramophone/gp/formatting.py new file mode 100644 index 0000000..45a105c --- /dev/null +++ b/gramophone/gp/formatting.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import json + +class Formatter: + + def __init__(self): + """ + The constructor. + """ + pass + + def encode(self, io_tuples, fmt): + + fmt = fmt.strip().lower() + + if fmt == "txt": + return "\n".join("%s\t%s" % (triple[0], triple[1]) for triple in io_tuples) + + elif fmt == "json": + result = [] + for triple in io_tuples: + result.append({"word" : triple[0], "phonology" : triple[1], "probability" : "%.5f" % triple[2]}) + return json.dumps(result) + else: + return str(io_tuples) diff --git a/gramophone/scripts/gramophone_server.py b/gramophone/scripts/gramophone_server.py index 1157b6e..5c1e2cd 100644 --- a/gramophone/scripts/gramophone_server.py +++ b/gramophone/scripts/gramophone_server.py @@ -29,9 +29,13 @@ def run(mapping,crf,lm): click.echo(u"...n-gram language model", err=True) rater = gp.Rater.load(lm) + formatter = gp.Formatter() + # # load app and run # - app = apps.create_gp_app(aligner,transcriber,rater) + app = apps.create_gp_app(aligner,transcriber,rater,formatter) app.run() + +#000FB527B344 From 83c6a1fc56fca5abfab329f0e649a466db2d5dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay-Michael=20W=C3=BCrzner?= Date: Fri, 1 Jun 2018 14:37:23 +0200 Subject: [PATCH 3/7] * start app --- gramophone/scripts/gramophone_server.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/gramophone/scripts/gramophone_server.py b/gramophone/scripts/gramophone_server.py index 5c1e2cd..d5b5107 100644 --- a/gramophone/scripts/gramophone_server.py +++ b/gramophone/scripts/gramophone_server.py @@ -37,5 +37,3 @@ def run(mapping,crf,lm): # app = apps.create_gp_app(aligner,transcriber,rater,formatter) app.run() - -#000FB527B344 From a02ca81512d0b8604b2a62645f06610a937d2c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay-Michael=20W=C3=BCrzner?= Date: Thu, 9 Nov 2017 15:11:36 +0100 Subject: [PATCH 4/7] * working transcription per GET --- .gitignore | 3 ++- gramophone/apps/gp_app.py | 28 ++++++++++++++++++++++--- gramophone/scripts/gramophone.py | 2 +- gramophone/scripts/gramophone_server.py | 27 ++++++++++++++++++++++-- setup.py | 2 +- 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 7a3c805..bc233f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ env/ -*.swp .cache/ .pytest_cache/ *__pycache__* *.egg-info/ +# vim swap files +*.swp diff --git a/gramophone/apps/gp_app.py b/gramophone/apps/gp_app.py index e362d43..0f57cfd 100644 --- a/gramophone/apps/gp_app.py +++ b/gramophone/apps/gp_app.py @@ -1,12 +1,34 @@ from __future__ import absolute_import from flask import Flask +from flask import request -def create_gp_app(mapping): +def create_gp_app(aligner,transcriber,rater): app = Flask(__name__) - @app.route('/gp') + @app.route('/gp/', methods=['GET', 'POST']) def index(): - return mapping + if request.method == 'GET': + + results = [] + strings = request.args.getlist('w') + for string in strings: + segmentations = aligner.scan(string.lower()) + best_transcription = [] + best_prob = 0.0 + for segmentation in segmentations: + transcriptions = transcriber.transcribe(segmentation) + for transcription in transcriptions: + prob = rater.rate([segmentation,transcription]) + #click.echo("%s: %f" % (u",".join(transcription),prob), err=True) + if prob >= best_prob: + best_prob = prob + best_transcription = transcription + results.append(u",".join(best_transcription)) + + return str(results) + + elif request.method == 'POST': + return str(request.form) return app diff --git a/gramophone/scripts/gramophone.py b/gramophone/scripts/gramophone.py index ebf0095..d0d4870 100644 --- a/gramophone/scripts/gramophone.py +++ b/gramophone/scripts/gramophone.py @@ -129,7 +129,7 @@ def apply_gp(mapping,crf,lm,strings): # convert for string in in_strings: - segmentations = aligner.scan(string) + segmentations = aligner.scan(string.lower()) best_transcription = [] best_prob = 0.0 for segmentation in segmentations: diff --git a/gramophone/scripts/gramophone_server.py b/gramophone/scripts/gramophone_server.py index b83047a..1157b6e 100644 --- a/gramophone/scripts/gramophone_server.py +++ b/gramophone/scripts/gramophone_server.py @@ -3,12 +3,35 @@ import click from gramophone import apps +from gramophone import gp @click.command() @click.option('-M', '--mapping', required=True, help='grapheme-phoneme mapping') -def run(mapping): +@click.option('-c', '--crf', required=True, help='transcription CRF model') +@click.option('-l', '--language-model', 'lm', required=True, help='rating language model') +def run(mapping,crf,lm): """ Run the application """ - app = apps.create_gp_app(mapping) + + # + # loading + # + click.echo(u"Loading...", err=True) + + click.echo(u"...data alignment", err=True) + aligner = gp.Aligner(mapping=mapping) + + click.echo(u"...transcription CRF model", err=True) + transcriber = gp.Transcriber() + transcriber.load(crf) + + click.echo(u"...n-gram language model", err=True) + rater = gp.Rater.load(lm) + + + # + # load app and run + # + app = apps.create_gp_app(aligner,transcriber,rater) app.run() diff --git a/setup.py b/setup.py index 608033e..52096a1 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ entry_points={ 'console_scripts': [ 'gramophone=gramophone.scripts.gramophone:cli', - 'gramophone_server=gramophone.scripts.gramophone_server:run', + 'gramophone-server=gramophone.scripts.gramophone_server:run', ] }, ) From 5c3152e164efa372425ede6e2dc2a4eb0fd0d142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay-Michael=20W=C3=BCrzner?= Date: Wed, 15 Nov 2017 17:06:50 +0100 Subject: [PATCH 5/7] result formatting --- .gitignore | 2 ++ gramophone/apps/gp_app.py | 15 ++++++++++---- gramophone/gp/__init__.py | 1 + gramophone/gp/alignment.py | 10 +++++++--- gramophone/gp/formatting.py | 26 +++++++++++++++++++++++++ gramophone/scripts/gramophone_server.py | 6 +++++- 6 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 gramophone/gp/formatting.py diff --git a/.gitignore b/.gitignore index bc233f8..095c030 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ env/ *.egg-info/ # vim swap files *.swp +# pyc files +*.pyc diff --git a/gramophone/apps/gp_app.py b/gramophone/apps/gp_app.py index 0f57cfd..0856426 100644 --- a/gramophone/apps/gp_app.py +++ b/gramophone/apps/gp_app.py @@ -3,15 +3,22 @@ from flask import Flask from flask import request -def create_gp_app(aligner,transcriber,rater): +def create_gp_app(aligner,transcriber,rater,formatter): app = Flask(__name__) @app.route('/gp/', methods=['GET', 'POST']) def index(): if request.method == 'GET': - results = [] + # get args strings = request.args.getlist('w') + formats = request.args.getlist('f') + + oformat = "" + if formats: + oformat = formats[0] + + results = [] for string in strings: segmentations = aligner.scan(string.lower()) best_transcription = [] @@ -24,9 +31,9 @@ def index(): if prob >= best_prob: best_prob = prob best_transcription = transcription - results.append(u",".join(best_transcription)) + results.append((string,u",".join(best_transcription),prob)) - return str(results) + return formatter.encode(results,oformat) elif request.method == 'POST': return str(request.form) diff --git a/gramophone/gp/__init__.py b/gramophone/gp/__init__.py index 24c99dc..45d21ef 100644 --- a/gramophone/gp/__init__.py +++ b/gramophone/gp/__init__.py @@ -1,3 +1,4 @@ from .alignment import Aligner from .transcription import Transcriber from .rating import Rater +from .formatting import Formatter diff --git a/gramophone/gp/alignment.py b/gramophone/gp/alignment.py index 96a6451..91fb08b 100644 --- a/gramophone/gp/alignment.py +++ b/gramophone/gp/alignment.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import sys import pywrapfst as fst import regex as re @@ -41,9 +40,15 @@ def chain(self,g): t.set_output_symbols(self.syms) src = t.add_state() t.set_start(src) + dest = src for c in g: + # skip unknown symbols + try: + s = self.syms.find(c) + except: + continue dest = t.add_state() - t.add_arc(src,fst.Arc(self.syms.find(c), self.syms.find(c), "0", dest)) + t.add_arc(src,fst.Arc(s, s, "0", dest)) src = dest t.set_final(dest) return t @@ -89,7 +94,6 @@ def __align_fst(self,g,p): t4.project(project_output=True) if t4.num_arcs(t4.start()) == 0: - sys.stderr.write(u"Empty expansion: %s %s\n" % (g, p)) return fst.Fst() t5 = fst.compose(t3,self.E) diff --git a/gramophone/gp/formatting.py b/gramophone/gp/formatting.py new file mode 100644 index 0000000..45a105c --- /dev/null +++ b/gramophone/gp/formatting.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import json + +class Formatter: + + def __init__(self): + """ + The constructor. + """ + pass + + def encode(self, io_tuples, fmt): + + fmt = fmt.strip().lower() + + if fmt == "txt": + return "\n".join("%s\t%s" % (triple[0], triple[1]) for triple in io_tuples) + + elif fmt == "json": + result = [] + for triple in io_tuples: + result.append({"word" : triple[0], "phonology" : triple[1], "probability" : "%.5f" % triple[2]}) + return json.dumps(result) + else: + return str(io_tuples) diff --git a/gramophone/scripts/gramophone_server.py b/gramophone/scripts/gramophone_server.py index 1157b6e..5c1e2cd 100644 --- a/gramophone/scripts/gramophone_server.py +++ b/gramophone/scripts/gramophone_server.py @@ -29,9 +29,13 @@ def run(mapping,crf,lm): click.echo(u"...n-gram language model", err=True) rater = gp.Rater.load(lm) + formatter = gp.Formatter() + # # load app and run # - app = apps.create_gp_app(aligner,transcriber,rater) + app = apps.create_gp_app(aligner,transcriber,rater,formatter) app.run() + +#000FB527B344 From 5c5f55e9f9a0b35617a0662067eccce0a14edc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay-Michael=20W=C3=BCrzner?= Date: Fri, 1 Jun 2018 14:37:23 +0200 Subject: [PATCH 6/7] * start app --- gramophone/scripts/gramophone_server.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/gramophone/scripts/gramophone_server.py b/gramophone/scripts/gramophone_server.py index 5c1e2cd..d5b5107 100644 --- a/gramophone/scripts/gramophone_server.py +++ b/gramophone/scripts/gramophone_server.py @@ -37,5 +37,3 @@ def run(mapping,crf,lm): # app = apps.create_gp_app(aligner,transcriber,rater,formatter) app.run() - -#000FB527B344 From 5b2bd9cc96d7035a0b6ab58069c199c83b44c0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay-Michael=20W=C3=BCrzner?= Date: Fri, 29 Jun 2018 18:01:51 +0200 Subject: [PATCH 7/7] * added server for hyphenation --- gramophone/apps/__init__.py | 1 + gramophone/apps/hy_app.py | 36 ++++++++++++++++++++++ gramophone/hy/__init__.py | 1 + gramophone/hy/formatting.py | 26 ++++++++++++++++ gramophone/scripts/gramophone.py | 4 +-- gramophone/scripts/gramophone_server.py | 40 +++++++++++++++++++++++-- setup.py | 2 +- 7 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 gramophone/apps/hy_app.py create mode 100644 gramophone/hy/formatting.py diff --git a/gramophone/apps/__init__.py b/gramophone/apps/__init__.py index f50b57a..195a260 100644 --- a/gramophone/apps/__init__.py +++ b/gramophone/apps/__init__.py @@ -1 +1,2 @@ from .gp_app import create_gp_app +from .hy_app import create_hy_app diff --git a/gramophone/apps/hy_app.py b/gramophone/apps/hy_app.py new file mode 100644 index 0000000..d9bc147 --- /dev/null +++ b/gramophone/apps/hy_app.py @@ -0,0 +1,36 @@ +from __future__ import absolute_import + +from flask import Flask +from flask import request + +def create_hy_app(coder,labeller,formatter): + app = Flask(__name__) + + @app.route('/hy/', methods=['GET', 'POST']) + def index(): + if request.method == 'GET': + + # get args + strings = request.args.getlist('w') + formats = request.args.getlist('f') + + oformat = "" + if formats: + oformat = formats[0] + + results = [] + for string in strings: + encodement = coder.encode(string,mode="scan") + labellings = labeller.label(encodement) + combination = [] + for labelling in labellings: + for i in range(len(encodement)): + combination.append(u"%s\t%s" % (encodement[i],labelling[i])) + results.append((string,coder.decode(combination))) + + return formatter.encode(results, oformat) + + elif request.method == 'POST': + return str(request.form) + + return app diff --git a/gramophone/hy/__init__.py b/gramophone/hy/__init__.py index 491d118..912cbc5 100644 --- a/gramophone/hy/__init__.py +++ b/gramophone/hy/__init__.py @@ -1,2 +1,3 @@ from .coding import Coder from .labelling import Labeller +from .formatting import Formatter diff --git a/gramophone/hy/formatting.py b/gramophone/hy/formatting.py new file mode 100644 index 0000000..cb98e05 --- /dev/null +++ b/gramophone/hy/formatting.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import json + +class Formatter: + + def __init__(self): + """ + The constructor. + """ + pass + + def encode(self, io_tuples, fmt): + + fmt = fmt.strip().lower() + + if fmt == "txt": + return "\n".join("%s\t%s" % (pair[0], pair[1]) for pair in io_tuples) + + elif fmt == "json": + result = [] + for pair in io_tuples: + result.append({"word" : pair[0], "hyphenation" : pair[1]}) + return json.dumps(result) + else: + return str(io_tuples) diff --git a/gramophone/scripts/gramophone.py b/gramophone/scripts/gramophone.py index d0d4870..91f7846 100644 --- a/gramophone/scripts/gramophone.py +++ b/gramophone/scripts/gramophone.py @@ -27,7 +27,7 @@ def HY(name="hy"): @click.option('-m', '--model', default='model', help='prefix of the output model files') @click.argument('data') def train_gp(mapping,model,data): - """Train a model""" + """Train a model.""" # # stage 1: alignment @@ -195,7 +195,7 @@ def train_hy(model,data): labeller.save(model + ".hy.crf") @HY.command(name="apply") -@click.option('-c', '--crf', required=True, help='transcription CRF model') +@click.option('-c', '--crf', required=True, help='hyphenation CRF model') @click.argument('strings', nargs=-1) def apply_hy(crf,strings): """Convert strings""" diff --git a/gramophone/scripts/gramophone_server.py b/gramophone/scripts/gramophone_server.py index d5b5107..37a92b7 100644 --- a/gramophone/scripts/gramophone_server.py +++ b/gramophone/scripts/gramophone_server.py @@ -4,14 +4,19 @@ from gramophone import apps from gramophone import gp +from gramophone import hy -@click.command() +@click.group() +def cli(): + pass + +@cli.command(name="gp") @click.option('-M', '--mapping', required=True, help='grapheme-phoneme mapping') @click.option('-c', '--crf', required=True, help='transcription CRF model') @click.option('-l', '--language-model', 'lm', required=True, help='rating language model') -def run(mapping,crf,lm): +def run_gp(mapping,crf,lm): """ - Run the application + Run the g2p server. """ # @@ -29,6 +34,7 @@ def run(mapping,crf,lm): click.echo(u"...n-gram language model", err=True) rater = gp.Rater.load(lm) + click.echo(u"...output formatter", err=True) formatter = gp.Formatter() @@ -37,3 +43,31 @@ def run(mapping,crf,lm): # app = apps.create_gp_app(aligner,transcriber,rater,formatter) app.run() + +@cli.command(name="hy") +@click.option('-c', '--crf', required=True, help='hyphenation CRF model') +def run_hy(crf): + """ + Run the hyphenation server. + """ + + # + # loading + # + click.echo(u"Loading...", err=True) + + click.echo(u"...coder", err=True) + coder = hy.Coder() + + click.echo(u"...hyphenation CRF model", err=True) + labeller = hy.Labeller() + labeller.load(crf) + + click.echo(u"...output formatter", err=True) + formatter = hy.Formatter() + + # + # load app and run + # + app = apps.create_hy_app(coder, labeller, formatter) + app.run() diff --git a/setup.py b/setup.py index 52096a1..5a3dbfa 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ entry_points={ 'console_scripts': [ 'gramophone=gramophone.scripts.gramophone:cli', - 'gramophone-server=gramophone.scripts.gramophone_server:run', + 'gramophone-server=gramophone.scripts.gramophone_server:cli', ] }, )