コード例 #1
0
    def getCategoryName(self, sentenceGraph, e1, e2, directed=True):
        # Dummies are potential entities that do not exist in the
        # training data. If both entities of an interaction are dummies
        # it can't exist in the training data and is therefore a negative
        if e1[2] or e2[2]:
            return "neg"

        e1 = e1[0]
        e2 = e2[0]

        interactions = sentenceGraph.getInteractions(e1, e2)
        if not directed:
            interactions.extend(sentenceGraph.getInteractions(e2, e1))

        types = set()
        for interaction in interactions:
            types.add(interaction.attrib["type"])
        types = list(types)
        types.sort()
        categoryName = ""
        for name in types:
            if categoryName != "":
                categoryName += "---"
            categoryName += name
        if categoryName != "":
            return categoryName
        else:
            return "neg"
コード例 #2
0
ファイル: doConfig.py プロジェクト: KeithLatteri/awips2
def getWx(wxtypes, wxvisibilities):
    from com.raytheon.uf.common.dataplugin.gfe.weather import WeatherCoverage, WeatherIntensity, WeatherAttribute
    from com.raytheon.edex.plugin.gfe.config import SimpleWeatherTypeConfig
    types = ArrayList()
    for t in wxtypes:
        symbol, description, cov, inten, attr = \
          check(t, (str, str, list, list, list), "Error in WeatherType")
        coverages = ArrayList()
        intensities = ArrayList()
        attributes = ArrayList()
        for c in cov:
            csym, cdes = check(c, (str, str), "Error in Weather Coverage", t)
            coverages.add(WeatherCoverage(csym, cdes))
        for i in inten:
            isym, ides = check(i, (str, str), "Error in Weather Intensity", t)
            intensities.add(WeatherIntensity(isym, ides))
        for a in attr:
            asym, ades = check(a, (str, str), "Error in Weather Attributes", t)
            attributes.add(WeatherAttribute(asym, ades))

        types.add(SimpleWeatherTypeConfig(symbol, description, coverages,
                          intensities, attributes))
    vis = ArrayList()
    for v in wxvisibilities:
        vis.add(v)
    return (vis, types)
コード例 #3
0
def getWx(wxtypes, wxvisibilities):
    from com.raytheon.uf.common.dataplugin.gfe.weather import WeatherCoverage, WeatherIntensity, WeatherAttribute
    from com.raytheon.edex.plugin.gfe.config import SimpleWeatherTypeConfig
    types = ArrayList()
    for t in wxtypes:
        symbol, description, cov, inten, attr = \
          check(t, (str, str, list, list, list), "Error in WeatherType")
        coverages = ArrayList()
        intensities = ArrayList()
        attributes = ArrayList()
        for c in cov:
            csym, cdes = check(c, (str, str), "Error in Weather Coverage", t)
            coverages.add(WeatherCoverage(csym, cdes))
        for i in inten:
            isym, ides = check(i, (str, str), "Error in Weather Intensity", t)
            intensities.add(WeatherIntensity(isym, ides))
        for a in attr:
            asym, ades = check(a, (str, str), "Error in Weather Attributes", t)
            attributes.add(WeatherAttribute(asym, ades))

        types.add(
            SimpleWeatherTypeConfig(symbol, description, coverages,
                                    intensities, attributes))
    vis = ArrayList()
    for v in wxvisibilities:
        vis.add(v)
    return (vis, types)
コード例 #4
0
 def lord_types(self):
     """Return a set of names of all lords in this legion."""
     types = set()
     for creature in self.creatures:
         if creature.is_lord:
             types.add(creature.name)
     return types
コード例 #5
0
 def getCategoryName(self, sentenceGraph, e1, e2, directed=True):
     # Dummies are potential entities that do not exist in the 
     # training data. If both entities of an interaction are dummies
     # it can't exist in the training data and is therefore a negative
     if e1[2] or e2[2]:
         return "neg"
     
     e1 = e1[0]
     e2 = e2[0]
     
     interactions = sentenceGraph.getInteractions(e1, e2)
     if not directed:
         interactions.extend(sentenceGraph.getInteractions(e2, e1))
     
     types = set()
     for interaction in interactions:
         types.add(interaction.attrib["type"])
     types = list(types)
     types.sort()
     categoryName = ""
     for name in types:
         if categoryName != "":
             categoryName += "---"
         categoryName += name
     if categoryName != "":
         return categoryName
     else:
         return "neg"           
コード例 #6
0
ファイル: Legion.py プロジェクト: dripton/Slugathon
 def lord_types(self):
     """Return a set of names of all lords in this legion."""
     types = set()
     for creature in self.creatures:
         if creature.is_lord:
             types.add(creature.name)
     return types
コード例 #7
0
def types():
    types = set()
    for t in _.__dict__.values():
        if isinstance(t, Type):
            types.add(t)
    t = list(t)
    return t
コード例 #8
0
 def getCategoryName(self, sentence1, sentence2, e1, e2, directed=True):
     """
     Example class. Multiple overlapping edges create a merged type.
     """
     e1Id = e1.get("id")
     e2Id = e2.get("id")
     allInteractions = sentence1.interSentenceInteractions + sentence2.interSentenceInteractions
     interactions = []
     #if len(allInteractions) > 0:
     #    print len(allInteractions)
     for interaction in allInteractions:
         if interaction.get("e1") == e1Id and interaction.get("e2") == e2Id:
             interactions.append(interaction)
     types = set()
     for interaction in interactions:
         types.add(interaction.get("type"))
     types = list(types)
     types.sort()
     categoryName = ""
     for name in types:
         if categoryName != "":
             categoryName += "---"
         categoryName += name
     if categoryName != "":
         return categoryName
     else:
         return "neg"
コード例 #9
0
ファイル: api_base.py プロジェクト: yushu9/rqalpha
def all_instruments(type=None, date=None):
    # type: (str, Union[str, datetime, date]) -> pd.DataFrame
    """
    获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。

    :param type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型
    :param date: 查询时间点

    其中type参数传入的合约类型和对应的解释如下:

    =========================   ===================================================
    合约类型                      说明
    =========================   ===================================================
    CS                          Common Stock, 即股票
    ETF                         Exchange Traded Fund, 即交易所交易基金
    LOF                         Listed Open-Ended Fund,即上市型开放式基金
    INDX                        Index, 即指数
    Future                      Futures,即期货,包含股指、国债和商品期货
    =========================   ===================================================

    """
    env = Environment.get_instance()
    if date is None:
        dt = env.trading_dt
    else:
        dt = pd.Timestamp(date).to_pydatetime()
        dt = min(dt, env.trading_dt)

    if type is not None:
        if isinstance(type, six.string_types):
            type = [type]

        types = set()
        for t in type:
            if t == "Stock":
                types.add("CS")
            elif t == "Fund":
                types.update(["ETF", "LOF"])
            else:
                types.add(t)
    else:
        types = None

    result = env.data_proxy.all_instruments(types, dt)
    if types is not None and len(types) == 1:
        data = []
        for i in result:
            instrument_dic = {k: v for k, v in i.__dict__.items() if not k.startswith("_")}
            data.append(instrument_dic)
        return pd.DataFrame(data)

    return pd.DataFrame(
        [
            [i.order_book_id, i.symbol, i.type, i.listed_date, i.de_listed_date]
            for i in result
        ],
        columns=["order_book_id", "symbol", "type", "listed_date", "de_listed_date"],
    )
コード例 #10
0
ファイル: _numba_types.py プロジェクト: mekman/numba
    def find_simple(self, seen):
        types = set()
        for type in self.types:
            if type.is_promotion:
                types.add(type.types)
            else:
                type.add(type)

        return types
コード例 #11
0
 def infer(self):
     p = self._signature_param
     evaluator = self.parent_context.evaluator
     types = set()
     if p.default is not p.empty:
         types.add(create(evaluator, p.default))
     if p.annotation is not p.empty:
         annotation = create(evaluator, p.annotation)
         types |= annotation.execute_evaluated()
     return types
コード例 #12
0
ファイル: __init__.py プロジェクト: ColossusPenguin/.emacs.d
 def infer(self):
     p = self._signature_param
     evaluator = self.parent_context.evaluator
     types = set()
     if p.default is not p.empty:
         types.add(create(evaluator, p.default))
     if p.annotation is not p.empty:
         annotation = create(evaluator, p.annotation)
         types |= annotation.execute_evaluated()
     return types
コード例 #13
0
ファイル: _numba_types.py プロジェクト: mekman/numba
 def dfs(self, types, seen):
     for type in self.types:
         if type not in seen:
             seen.add(type)
             type = resolve_type_chain(type)
             seen.add(type)
             if type.is_promotion:
                 type.dfs(types, seen)
             elif not type.is_uninitialized:
                 types.add(type)
コード例 #14
0
ファイル: task-6.py プロジェクト: AlisiaSmith/NSUPython2018
    def __cast_to_general_type(self):
        types = set()
        for coordinate in self._coordinates:
            if isinstance(coordinate, numbers.Number):
                types.add(type(coordinate))
            else:
                coordinate = self._parse(coordinate, (int, float, complex))
                types.add(type(coordinate))

        for i in (complex, float, int):
            if i in types:
                self._coordinates = [i(elem) for elem in self._coordinates]
                break
コード例 #15
0
ファイル: _numba_types.py プロジェクト: mekman/numba
    def add_type(self, seen, type, types):
        if type not in seen:
            if type.is_unresolved:
                seen.add(type)
                new_type = type.resolve()
                if new_type is not type:
                    seen.add(new_type)
                    self.add_type(seen, new_type, types)
                    type = new_type
                else:
                    types.add(type)
            else:
                types.add(type)

            return type
コード例 #16
0
ファイル: ModifierExampleBuilder.py プロジェクト: yumyai/TEES
 def getMergedEntityType(self, entities):
     """
     If a single token belongs to multiple entities of different types,
     a new, composite type is defined. This type is the alphabetically
     ordered types of these entities joined with '---'.
     """
     types = set()
     for entity in entities:
         types.add(entity.get("type"))
     types = list(types)
     types.sort()
     typeString = ""
     for type in types:
         if typeString != "":
             typeString += "---"
         typeString += type
     return typeString
コード例 #17
0
 def getMergedEntityType(self, entities):
     """
     If a single token belongs to multiple entities of different types,
     a new, composite type is defined. This type is the alphabetically
     ordered types of these entities joined with '---'.
     """
     types = set()
     for entity in entities:
         types.add(entity.get("type"))
     types = list(types)
     types.sort()
     typeString = ""
     for type in types:
         if typeString != "":
             typeString += "---"
         typeString += type
     return typeString
コード例 #18
0
def all_instruments(type=None, date=None):
    """
    获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。

    :param str type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型

    :param date: 查询时间点
    :type date: `str` | `datetime` | `date`


    :return: `pandas DataFrame` 所有合约的基本信息。

    其中type参数传入的合约类型和对应的解释如下:

    =========================   ===================================================
    合约类型                      说明
    =========================   ===================================================
    CS                          Common Stock, 即股票
    ETF                         Exchange Traded Fund, 即交易所交易基金
    LOF                         Listed Open-Ended Fund,即上市型开放式基金
    FenjiMu                     Fenji Mu Fund, 即分级母基金
    FenjiA                      Fenji A Fund, 即分级A类基金
    FenjiB                      Fenji B Funds, 即分级B类基金
    INDX                        Index, 即指数
    Future                      Futures,即期货,包含股指、国债和商品期货
    =========================   ===================================================

    :example:

    获取中国市场所有分级基金的基础信息:

    ..  code-block:: python3
        :linenos:

        [In]all_instruments('FenjiA')
        [Out]
            abbrev_symbol    order_book_id    product    sector_code  symbol
        0    CYGA    150303.XSHE    null    null    华安创业板50A
        1    JY500A    150088.XSHE    null    null    金鹰500A
        2    TD500A    150053.XSHE    null    null    泰达稳健
        3    HS500A    150110.XSHE    null    null    华商500A
        4    QSAJ    150235.XSHE    null    null    鹏华证券A
        ...

    """
    env = Environment.get_instance()
    if date is None:
        dt = env.trading_dt
    else:
        dt = pd.Timestamp(date).to_pydatetime()
        dt = min(dt, env.trading_dt)

    if type is not None:
        if isinstance(type, six.string_types):
            type = [type]

        types = set()
        for t in type:
            if t == 'Stock':
                types.add('CS')
            elif t == 'Fund':
                types.update(['ETF', 'LOF', 'SF', 'FenjiA', 'FenjiB', 'FenjiMu'])
            else:
                types.add(t)
    else:
        types = None

    result = env.data_proxy.all_instruments(types, dt)
    if types is not None and len(types) == 1:
        return pd.DataFrame([i._ins_dict for i in result])

    return pd.DataFrame(
        [[i.order_book_id, i.symbol, i.type, i.listed_date, i.de_listed_date] for i in result],
        columns=['order_book_id', 'symbol', 'type', 'listed_date', 'de_listed_date'])
コード例 #19
0
ファイル: api_base.py プロジェクト: ricequant/rqalpha
def all_instruments(type=None, date=None):
    """
    获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。

    :param str type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型

    :param date: 查询时间点
    :type date: `str` | `datetime` | `date`


    :return: `pandas DataFrame` 所有合约的基本信息。

    其中type参数传入的合约类型和对应的解释如下:

    =========================   ===================================================
    合约类型                      说明
    =========================   ===================================================
    CS                          Common Stock, 即股票
    ETF                         Exchange Traded Fund, 即交易所交易基金
    LOF                         Listed Open-Ended Fund,即上市型开放式基金
    FenjiMu                     Fenji Mu Fund, 即分级母基金
    FenjiA                      Fenji A Fund, 即分级A类基金
    FenjiB                      Fenji B Funds, 即分级B类基金
    INDX                        Index, 即指数
    Future                      Futures,即期货,包含股指、国债和商品期货
    =========================   ===================================================

    :example:

    获取中国市场所有分级基金的基础信息:

    ..  code-block:: python3
        :linenos:

        [In]all_instruments('FenjiA')
        [Out]
            abbrev_symbol    order_book_id    product    sector_code  symbol
        0    CYGA    150303.XSHE    null    null    华安创业板50A
        1    JY500A    150088.XSHE    null    null    金鹰500A
        2    TD500A    150053.XSHE    null    null    泰达稳健
        3    HS500A    150110.XSHE    null    null    华商500A
        4    QSAJ    150235.XSHE    null    null    鹏华证券A
        ...

    """
    env = Environment.get_instance()
    if date is None:
        dt = env.trading_dt
    else:
        dt = pd.Timestamp(date).to_pydatetime()
        dt = min(dt, env.trading_dt)

    if type is not None:
        if isinstance(type, six.string_types):
            type = [type]

        types = set()
        for t in type:
            if t == "Stock":
                types.add("CS")
            elif t == "Fund":
                types.update(["ETF", "LOF", "SF", "FenjiA", "FenjiB", "FenjiMu"])
            else:
                types.add(t)
    else:
        types = None

    result = env.data_proxy.all_instruments(types, dt)
    if types is not None and len(types) == 1:
        return pd.DataFrame([i.__dict__ for i in result])

    return pd.DataFrame(
        [
            [i.order_book_id, i.symbol, i.type, i.listed_date, i.de_listed_date]
            for i in result
        ],
        columns=["order_book_id", "symbol", "type", "listed_date", "de_listed_date"],
    )