Ejemplo n.º 1
0
def mongo_init():
    config = json.load(open(relative(__file__, "config/mongoconfig.json")))
    dao = MongoDAO(
        host=config["host"],
        port=config["port"],
        db_name=config["dbName"],
    )
    init_db(dao)
Ejemplo n.º 2
0
def modRole(semR, env, opts):
    def simpleModNoun(concept, neg):  ## check for "simple" cases
        if concept in [
                "all", "many", "both", "no", "too", "any", "other", "some",
                "one", "kind-yy", "then", "such"
        ]:
            env.put(":D", Q("kind of" if concept == "kind-yy" else concept))
            if neg: env.unshift(Q("not"))
            if concept in ["all", "many", "both"]:
                opts.add("n", "p")
        elif concept in determiners:
            env.put(":D", D(concept))
        elif is_number(concept):
            env.push(NO(concept))
        elif isNoun(concept):  ## prefix the :mod for nouns
            newNoun = N(nouns[concept].lemma)  # keep only noun from NP
            if ":A" in env:
                env.insertAfter(":A", ":A", newNoun)
            else:
                env.put(":A", newNoun)
            if neg: env.insertBefore(":A", ":A", Q("non"))
        elif isAdjective(concept):  ## postfix the :mod for adjectives
            newAdj = A(adjectives[concept].lemma)
            if ":A" in env:
                env.insertAfter(":A", ":A", newAdj)
            else:
                env.put(":A", newAdj)
            if neg: env.insertBefore(":A", ":A", Q("non"))
        elif isAdverb(concept):
            env.put(":D", Adv(concept))
        elif isVerb(concept):
            env.push(V(re.sub(r"-\d+$", '', concept)).t("pr"))
        elif semR.roles.areEmpty():  ## equivalent to processSimpleModOther
            env.push(Q(generateConceptWord(concept)))
        else:
            return False
        return True

    traceSyntR("modRole", semR)
    concept = semR.get_concept()
    if concept == None:
        env.push(makeSyntR(semR))
        return
    roles = semR.roles
    neg = False
    if hasNegPolarity(
            roles):  # negation will be applied to the generated relative
        neg = True
    if roles.areEmpty():
        simpleModNoun(concept, neg)
        return
    syntR = makeSyntR(semR)
    if isinstance(syntR, (N, NP)):
        env.push(PP(P("of"), syntR))
    else:
        rel = relative(concept, syntR)
        if neg: rel.typ({"neg": True})
        env.push(rel)
Ejemplo n.º 3
0
def create_dao(db: str) -> BaseDAO:
    if db == 'mongo':
        config = json.load(open(relative(__file__,
                                         "config/mongoconfig.json")), )
        return MongoDAO(
            host=config["host"],
            port=config["port"],
            db_name=config["dbName"],
        )
    elif db == 'mysql':
        return DAO()
Ejemplo n.º 4
0
def get_response(operation_name, data):
    endpoint = "https://svcs.ebay.com/services/search/BestMatchItemDetailsService/v1"
    config = ConfigParser()
    config.read(relative("..", "config", "config.ini"))
    access_token = config.get("auth", "token")

    http_headers = {"X-EBAY-SOA-OPERATION-NAME": operation_name, "X-EBAY-SOA-SECURITY-TOKEN": access_token}

    req = urllib2.Request(endpoint, data, http_headers)
    res = urllib2.urlopen(req)
    data = res.read()
    return data
Ejemplo n.º 5
0
def get_response(user_params):
    config = ConfigParser()
    config.read(relative("config.ini"))

    app_id = config.get("keys", "app_name")
    site_id = config.get("call", "siteid")
    version = config.get("call", "compatibility_level")
    endpoint = config.get("endpoints", "client_alerts")

    d = dict(appid=app_id, siteid=site_id, version=version)
    d.update(user_params)

    return requests.get(endpoint, params=d)
Ejemplo n.º 6
0
def get_response(user_params):
    config = ConfigParser()
    config.read(relative("..", "config", "config.ini"))
    
    app_id = config.get("keys", "app_name")
    site_id = config.get("call", "siteid")
    version = config.get("call", "compatibility_level")
    endpoint = config.get("endpoints", "client_alerts")

    d=dict(appid = app_id, siteid = site_id, version = version)
    d.update(user_params)

    return requests.get(endpoint, params=d)
Ejemplo n.º 7
0
def get_response(operation_name, data, **headers):
    config = ConfigParser()
    config.read(relative("..", "config", "config.ini"))
    app_name = config.get("keys", "app_name")
    endpoint = config.get("endpoints", "product")

    http_headers = {"X-EBAY-SOA-OPERATION-NAME": operation_name,
                    "X-EBAY-SOA-SECURITY-APPNAME": app_name}
   
    http_headers.update(headers)
    
    req = urllib2.Request(endpoint, data, http_headers)
    res = urllib2.urlopen(req)
    data = res.read()
    return data
def get_response(operation_name, data, **headers):
    config = ConfigParser()
    config.read(relative("..", "config", "config.ini"))
    access_token = config.get("auth", "token")
    endpoint = config.get("endpoints", "resolution_case_management")

    http_headers = {"X-EBAY-SOA-OPERATION-NAME": operation_name,
                    "X-EBAY-SOA-SECURITY-TOKEN": access_token}
   
    http_headers.update(headers)
    
    req = urllib2.Request(endpoint, data, http_headers)
    res = urllib2.urlopen(req)
    data = res.read()
    return data
Ejemplo n.º 9
0
def get_response(user_params):
    endpoint = "http://open.api.sandbox.ebay.com/shopping"
    
    config = ConfigParser()
    config.read(relative("..", "config", "config.ini"))
    
    app_id = config.get("keys", "app_name")
    site_id = config.get("call", "siteid")
    version = config.get("call", "compatibility_level")

    d=dict(appid = app_id, siteid = site_id, version = version)
    
    d.update(user_params)
    
    return requests.get(endpoint, params=d)
def get_response(operation_name, data, encoding, **headers):
    config = ConfigParser()
    config.read(relative("config.ini"))
    access_token = config.get("auth", "token")
    endpoint = config.get("endpoints", "resolution_case_management")

    http_headers = {"X-EBAY-SOA-OPERATION-NAME": operation_name,
                    "X-EBAY-SOA-SECURITY-TOKEN": access_token,
                    "X-EBAY-SOA-RESPONSE-DATA-FORMAT": encoding}

    http_headers.update(headers)

    req = urllib2.Request(endpoint, data, http_headers)
    res = urllib2.urlopen(req)
    data = res.read()
    return data
Ejemplo n.º 11
0
def get_response(operation_name, data, encoding, **headers):
    config = ConfigParser()
    config.read(relative("config.ini"))
    app_name = config.get("keys", "app_name")
    endpoint = config.get("endpoints", "merchandising")

    http_headers = {"X-EBAY-SOA-OPERATION-NAME": operation_name,
                    "EBAY-SOA-CONSUMER-ID": app_name,
                    "X-EBAY-SOA-RESPONSE-DATA-FORMAT": encoding}

    http_headers.update(headers)

    req = urllib2.Request(endpoint, data, http_headers)
    res = urllib2.urlopen(req)
    data = res.read()
    return data
Ejemplo n.º 12
0
def get_response(operation_name, data, encoding, **headers):
    config = ConfigParser()
    config.read(relative("config.ini"))
    app_name = config.get("keys", "app_name")
    endpoint = config.get("endpoints", "finding")

    http_headers = {"X-EBAY-SOA-OPERATION-NAME": operation_name,
                    "X-EBAY-SOA-SECURITY-APPNAME": app_name,
                    "X-EBAY-SOA-RESPONSE-DATA-FORMAT": encoding}

    http_headers.update(headers)

    req = urllib2.Request(endpoint, data, http_headers)
    res = urllib2.urlopen(req)
    data = res.read()
    return data
Ejemplo n.º 13
0
def get_response(operation_name, data, encoding, **headers):
    config = ConfigParser()
    config.read(relative("..", "config", "config.ini"))
    access_token = config.get("auth", "token_prod")
    endpoint = config.get("endpoints", "best_match")

    http_headers = {"X-EBAY-SOA-OPERATION-NAME": operation_name,
                    "X-EBAY-SOA-SECURITY-TOKEN": access_token,
                    "X-EBAY-SOA-RESPONSE-DATA-FORMAT": encoding}

    http_headers.update(headers)

    req = urllib2.Request(endpoint, data, http_headers)
    res = urllib2.urlopen(req)
    data = res.read()
    return data
Ejemplo n.º 14
0
def get_response(operation_name, data, encoding, **headers):
    config = ConfigParser()
    config.read(relative("config.ini"))
    globalId = config.get("call", "global_id")
    app_name = config.get("keys", "app_name")
    endpoint = config.get("endpoints", "finding")

    http_headers = {"X-EBAY-SOA-OPERATION-NAME": operation_name,
                    "X-EBAY-SOA-SECURITY-APPNAME": app_name,
                    "X-EBAY-SOA-GLOBAL-ID" : globalId,
                    "X-EBAY-SOA-RESPONSE-DATA-FORMAT": encoding}

    http_headers.update(headers)

    req = urllib2.Request(endpoint, data, http_headers)
    res = urllib2.urlopen(req)
    data = res.read()
    return data
Ejemplo n.º 15
0
def rlt(X, L_0=64, gamma=None, i_max=100):
    """
      This function implements Algorithm 1 for one sample of landmarks.

    Args:
      X: np.array representing the dataset.
      L_0: number of landmarks to sample.
      gamma: float, parameter determining the maximum persistence value.
      i_max: int, upper bound on the value of beta_1 to compute.

    Returns
      An array of size (i_max, ) containing RLT(i, 1, X, L)
      for randomly sampled landmarks.
    """
    if not isinstance(X, np.ndarray):
        raise ValueError('X should be a numpy array')
    if len(X.shape) != 2:
        raise ValueError('X should be 2d array, got shape {}'.format(X.shape))
    N = X.shape[0]
    if gamma is None:
        gamma = 1.0 / 128 * N / 5000
    I_1, alpha_max = witness(X, L_0=L_0, gamma=gamma)
    res = relative(I_1, alpha_max, i_max=i_max)
    return res
Ejemplo n.º 16
0
def init_db(dao: BaseDAO):
    dao.connect_to_database()
    dao.drop_tables()
    dao.create_tables()
    dao.add_user("paj", "Paul", "Johnston", "123")
    user_names = ["paj"]
    dao.add_campus("Provo", "Utah", "BYU-Provo")
    dao.add_campus("Rexburg", "Idaho", "BYU-Idaho")
    dao.add_campus("Laie", "Hawaii", "BYU-Hawaii")
    dao.add_campus("SLC", "Utah", "BYU-SLC")
    campus_idProvo = dao.get_campus_id("BYU-Provo")
    campus_idRexburg = dao.get_campus_id("BYU-Idaho")
    campus_idLaie = dao.get_campus_id("BYU-Hawaii")
    campus_idSLC = dao.get_campus_id("BYU-SLC")
    building_names = []
    # Provo Campus
    myDF = pd.read_csv(
        relative(__file__, "Building_Coordinates.csv"),
        sep=",",
    )

    for i in range(0, len(myDF.index)):
        dao.add_building(
            myDF["Name"][i],
            float(myDF["Latitude"][i]),
            float(myDF["Longitude"][i]),
            campus_idProvo,
        )

        building_names.append(myDF["Name"][i])

    # Rexburg Campus
    myDF = pd.read_csv(
        relative(__file__, "Buildings_Rexburg.csv"),
        sep=",",
    )

    for i in range(0, len(myDF.index)):
        dao.add_building(
            myDF["Name"][i],
            float(myDF["Latitude"][i]),
            float(myDF["Longitude"][i]),
            campus_idRexburg,
        )

        building_names.append(myDF["Name"][i])

    # Laie Campus
    myDF = pd.read_csv(
        relative(__file__, "Buildings_Laie.csv"),
        sep=",",
    )

    for i in range(0, len(myDF.index)):
        dao.add_building(
            myDF["Name"][i],
            float(myDF["Latitude"][i]),
            float(myDF["Longitude"][i]),
            campus_idLaie,
        )

        building_names.append(myDF["Name"][i])

    # SLC Campus
    myDF = pd.read_csv(
        relative(__file__, "Buildings_SLC.csv"),
        sep=",",
    )

    for i in range(0, len(myDF.index)):
        dao.add_building(
            myDF["Name"][i],
            float(myDF["Latitude"][i]),
            float(myDF["Longitude"][i]),
            campus_idSLC,
        )

        building_names.append(myDF["Name"][i])

    # Fountains
    fountainData = pd.read_csv(
        relative(__file__, "FountainInput.csv"),
        sep=",",
    )

    fountain_names = []

    for i in range(0, len(fountainData.index)):
        building_idx = int(fountainData["Building_ID"][i]) - 1
        building_name = building_names[building_idx]
        building_id = dao.get_building_id(building_name)

        dao.add_fountain(
            building_id,
            str(fountainData["Fountain_Name"][i]),
        )

        fountain_names.append(fountainData["Fountain_Name"][i])

    ratingData = pd.read_csv(
        relative(__file__, "ratingInput.csv"),
        sep=",",
    )

    for i in range(0, len(ratingData.index)):
        fountain_idx = int(ratingData["Fountain_ID"][i]) - 1
        fountain_name = fountain_names[fountain_idx]
        fountain_id = dao.lookup_fountain(fountain_name)["id"]

        user_idx = int(ratingData["User_ID"][i]) - 1
        user_name = user_names[user_idx]
        user_id = dao.get_user_id(user_name)

        dao.add_rating(
            int(ratingData["Score"][i]),
            str(ratingData["Date"][i]),
            fountain_id,
            user_id,
        )

    dao.disconnect_from_database()
Ejemplo n.º 17
0
import urllib2
from lxml import etree
from ConfigParser import ConfigParser
from utils import relative

config = ConfigParser()
config.read(relative("..", "config", "config.ini"))
dev_name = config.get("keys", "dev_name")
app_name = config.get("keys", "app_name")
cert_name = config.get("keys", "cert_name")
compatibility_level = config.get("call", "compatibility_level")
token = config.get("auth", "token")
endpoint = config.get("endpoints", "trading")

# Maps Ebay global ID TO Ebay site ID
map_site__global_id = {'EBAY-AT':16,'EBAY-AU':15,'EBAY-CH':193,'EBAY-DE':77,'EBAY-ENCA':2,'EBAY-ES':186,'EBAY-FR':71,'EBAY-FRBE':23,'EBAY-FRCA':210,'EBAY-GB':3,'EBAY-HK':201,'EBAY-IE':205,'EBAY-IN':203,'EBAY-IT':101,'EBAY-MOTOR':100,'EBAY-MY':207,'EBAY-NL':146,'EBAY-NLBE':123,'EBAY-PH':211,'EBAY-PL':212,'EBAY-SG':216,'EBAY-US':0}


def getCategories(global_id, category_parent=None,  level_limit=None, view_all_nodes=None, detail_level='ReturnAll', error_language=None, message_id=None, output_selectors=None, version=None, warning_level=None):
    root = etree.Element("GetCategoriesRequest", xmlns="urn:ebay:apis:eBLBaseComponents")
    add_standard_fields(root, detail_level, error_language, message_id, output_selectors, version, warning_level)
    sub_element(root, 'CategoryParent', category_parent)
    sub_element(root, 'CategorySiteID', map_site__global_id[global_id])
    sub_element(root, 'LevelLimit', level_limit)
    sub_element(root, 'ViewAllNodes', view_all_nodes)
    request = etree.tostring(root, pretty_print=True)
    return get_response('GetCategories', request)


def getItem(global_id, item_id, include_watch_count, detail_level='ReturnAll', error_language=None, message_id=None, output_selectors=None, version=None, warning_level=None):
    root = etree.Element("GetItemRequest", xmlns="urn:ebay:apis:eBLBaseComponents")
Ejemplo n.º 18
0
# General Django settings for mysite project.

import os
import sys
import django.conf.global_settings as DEFAULT_SETTINGS
import utils
import logging
import pipelinefiles

# Make Django root folder available
PROJECT_ROOT = utils.relative("..", "..")
# Add all subdirectories of project, applications and lib to sys.path
for subdirectory in ("projects", "applications", "lib"):
    full_path = os.path.join(PROJECT_ROOT, subdirectory)
    sys.path.insert(0, full_path)

# A list of people who get code error notifications. They will get an email
# if DEBUG=False and a view raises an exception.
ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

# At the moment CATMAID doesn't support internationalization and all strings are
# expected to be in English.
LANGUAGE_CODE = "en-gb"

# A tuple in the same format as ADMINS of people who get broken-link
# notifications when SEND_BROKEN_LINKS_EMAILS=True.
MANAGERS = ADMINS

# If you set this to False, Django will make some optimizations so as not
Ejemplo n.º 19
0
            #plt.plot(dp.numpy())
            #plt.plot(short)
            #plt.plot(longt)
            # plt.ylabel('some numbers')

            data_stream = [
                dp.clone(), short, longt, shorte, longe, conv_line, base_line,
                lead_span_a, lead_span_b
            ]
            for i in range(0, len(data_stream)):
                data_stream[i] = utils.locked_diff(data_stream[0],
                                                   data_stream[i])
            #  data_stream[0] = utils.change(data_stream[0])

            data_stream[0] = utils.relative(dp.numpy())

            clen = len(data_stream)

            for p in range(1, 30):
                for v in range(clen):
                    data_stream.append(utils.lookback(data_stream[v], p))

            for i in range(0, len(data_stream)):
                data_stream[i] = torch.tensor(data_stream[i],
                                              dtype=torch.float32)
            '''
            short = torch.tensor(short, dtype=torch.float32)
            longt = torch.tensor(longt, dtype=torch.float32)
            shorte = torch.tensor(shorte, dtype=torch.float32)
            longe = torch.tensor(longe, dtype=torch.float32)
Ejemplo n.º 20
0
# settings.py file:
# MIDDLEWARE_CLASSES += ('catmaid.middleware.FlyTEMMiddleware',)
# FLYTEM_SERVICE_URL = 'http://renderer-2.int.janelia.org:8080/render-ws/v1/owner/flyTEM'
# FLYTEM_STACK_RESOLUTION = (4,4,40)
# FLYTEM_STACK_TILE_WIDTH = 512
# FLYTEM_STACK_TILE_HEIGHT = 512

# DVID auto-discovery. To activate add the following lines to your settings.py
# file:
# MIDDLEWARE_CLASSES += ('catmaid.middleware.DVIDMiddleware',)
# DVID_URL = 'http://emdata2.int.janelia.org:7000'
# DVID_FORMAT = 'jpg:80'
# DVID_SHOW_NONDISPLAYABLE_REPOS = True

# Make Django root folder available
PROJECT_ROOT = utils.relative('..', '..')
# Add all subdirectories of project, applications and lib to sys.path
for subdirectory in ('projects', 'applications', 'lib'):
    full_path = os.path.join(PROJECT_ROOT, subdirectory)
    sys.path.insert(0, full_path)

# In order to make Django work with the unmanaged models from djsopnet in tests,
# we use a custom testing runner to detect when running in a testing
# environment. The custom PostgreSQL database wrapper uses this flag to change
# its behavior.
TEST_RUNNER = 'custom_testrunner.TestSuiteRunner'

# To simplify configuration for performance test CATMAID instances, the SCM URL
# used to create commit links is defined here. The {} is used to denote the
# commit name.
PERFORMANCETEST_SCM_URL = "https://github.com/catmaid/CATMAID/commit/{version}"
Ejemplo n.º 21
0
# General Django settings for mysite project.

import os
import sys
import django.conf.global_settings as DEFAULT_SETTINGS
import utils
import pipelinefiles

# Make Django root folder available
PROJECT_ROOT = utils.relative('..', '..')
# Add all subdirectories of project, applications and lib to sys.path
for subdirectory in ('projects', 'applications', 'lib'):
    full_path = os.path.join(PROJECT_ROOT, subdirectory)
    sys.path.insert(0, full_path)

# A list of people who get code error notifications. They will get an email
# if DEBUG=False and a view raises an exception.
ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

# At the moment CATMAID doesn't support internationalization and all strings are
# expected to be in English.
LANGUAGE_CODE = 'en-gb'

# A tuple in the same format as ADMINS of people who get broken-link
# notifications when SEND_BROKEN_LINKS_EMAILS=True.
MANAGERS = ADMINS

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.