forked from perseids-project/morphsvc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add legacy remote engine for aramorph
- Loading branch information
Bridget Almas
committed
Oct 12, 2017
1 parent
59a5e8e
commit ee7aac7
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |