Commit 616258ec authored by c24b's avatar c24b

RESOURCE_TYPE search methods

parent 5ad8c4e7
...@@ -125,22 +125,29 @@ LANGUAGES = { ...@@ -125,22 +125,29 @@ LANGUAGES = {
from gargantext.util.parsers import \ from gargantext.util.parsers import \
EuropressParser, RISParser, PubmedParser, ISIParser, CSVParser, ISTexParser, CernParser EuropressParser, RISParser, PubmedParser, ISIParser, CSVParser, ISTexParser, CernParser
def resourcetype(name): from gargantext.util.scrappers import \
CernScraper
def resourcetype(corpus_name):
''' '''
resourcetype :: String -> Int resourcetype Name :: Int
Usage : resourcetype("Europress (English)") == 1 Usage : resourcetype("Europress (English)") == 1
Examples in scrapers scripts (Pubmed or ISTex for instance). Examples in scrapers scripts (Pubmed or ISTex for instance).
''' '''
return [n[0] for n in enumerate(r['name'] for r in RESOURCETYPES) if n[1] == name][0] return [n["type"] for n in RESOURCETYPES if n["name"]== corpus_name][0]
def resourcename(corpus): def resourcename(corpus_type):
''' '''
resourcetype :: Corpus -> String resourcetype :: Corpus_type -> String
Usage : resourcename(corpus) == "ISTex" Usage : resourcename(corpus.type) == "ISTex"
''' '''
resource = corpus.resources()[0] resource = corpus.resources()[0]
resourcename = RESOURCETYPES[resource['type']]['name'] resourcename = RESOURCETYPES[resource['type']]['name']
return re.sub(r'\(.*', '', resourcename) return [n["name"] for n in RESOURCETYPES if n["type"]== corpus_type][0]
def get_resource(corpus):
print(corpus.items())
return
RESOURCETYPES = [ RESOURCETYPES = [
# type 0 # type 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment