Skip to content

Commit

Permalink
Add legacy remote engine for aramorph
Browse files Browse the repository at this point in the history
  • Loading branch information
Bridget Almas committed Oct 12, 2017
1 parent 59a5e8e commit ee7aac7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
5 changes: 3 additions & 2 deletions morphsvc/config.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ENGINES = "morpheusgrc,aramorph,whitakerLat,wleg,mgrcleg,hazm"
ENGINES = "morpheusgrc,aramorph,whitakerLat,wleg,mgrcleg,amleg,hazm"
ENGINES_MORPHEUSGRC_CNAME = "morphsvc.lib.engines.MorpheusLocalEngine.MorpheusLocalEngine"
ENGINES_MGRCLEG_CNAME = "morphsvc.lib.engines.MorpheusLegacyLocalEngine.MorpheusLegacyLocalEngine"
ENGINES_ARAMORPH_CNAME = "morphsvc.lib.engines.AramorphRemoteEngine.AramorphRemoteEngine"
ENGINES_AMLEG_CNAME = "morphsvc.lib.engines.AramorphLegacyRemoteEngine.AramorphLegacyRemoteEngine"
ENGINES_WHITAKERLAT_CNAME = "morphsvc.lib.engines.WhitakersLocalEngine.WhitakersLocalEngine"
ENGINES_WLEG_CNAME = "morphsvc.lib.engines.WhitakersLegacyLocalEngine.WhitakersLegacyLocalEngine"
ENGINES_HAZM_CNAME = "morphsvc.lib.engines.HazmEngine.HazmEngine"
Expand All @@ -10,7 +11,7 @@ PARSERS_MORPHEUS_STEMLIBDIR = "/home/balmas/workspace/morpheus/dist/stemlib"
PARSERS_MORPHEUS_URI = "org.perseus:tools:morpheus.v1"
PARSERS_ARAMORPH_URI = "net.alpheios:tools:aramorph.v2"
PARSERS_HAZM_URI = "org.PersDigUMD:tools.hazm.v2"
PARSERS_ARAMORPH_REMOTE_URL = "http://alpheios.net/perl/aramorph-test?word="
PARSERS_ARAMORPH_REMOTE_URL = "http://alpheios.net/perl/aramorph2?word="
PARSERS_WHITAKERS_URI = "net.alpheios:tools:wordsxml.v1"
PARSERS_WHITAKERS_PATH = "/home/balmas/workspace/wordsxml/dist/Linux_x86-gcc4/wordsxml"
SERVICES_LEXICAL_ENTITY_SVC_GRC = None
Expand Down
33 changes: 33 additions & 0 deletions morphsvc/lib/engines/AlpheiosLegacyRemoteEngine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from morphsvc.lib.engines.AlpheiosLegacyXmlEngine import AlpheiosLegacyXmlEngine
from subprocess import check_output
import itertools
from lxml import etree
from collections import Callable
import os, requests

class AlpheiosLegacyRemoteEngine(AlpheiosLegacyXmlEngine):


def __init__(self, code, config,**kwargs):
super(AlpheiosLegacyRemoteEngine, self).__init__(code, config,**kwargs)
self.code = code
self.language_codes = []
self.config = config
self.uri = ''
self.remote_url = ''
self.transformer = None


def lookup(self,word,word_uri,language,**kwargs):
if self.transformer is not None:
word = self.transformer.transform_input(word)
parsed = self._execute_query(word,language)
if self.transformer is not None:
transformed = self.transformer.transform_output(parsed)
else:
transformed = etree.XML(parsed)
return transformed

def _execute_query(self,word,language):
url = self.remote_url + word
return requests.get(url).text
13 changes: 13 additions & 0 deletions morphsvc/lib/engines/AramorphLegacyRemoteEngine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from morphsvc.lib.engines.AlpheiosLegacyRemoteEngine import AlpheiosLegacyRemoteEngine

class AramorphLegacyRemoteEngine(AlpheiosLegacyRemoteEngine):


def __init__(self,code, config,**kwargs):
super(AramorphLegacyRemoteEngine, self).__init__(code, config,**kwargs)
self.code = code
self.language_codes = ['ara', 'ar']
self.config = config
self.uri = self.config['PARSERS_ARAMORPH_URI']
self.remote_url = self.config['PARSERS_ARAMORPH_REMOTE_URL']
self.transformer = None

0 comments on commit ee7aac7

Please sign in to comment.