Ejemplo n.º 1
0
Position = fact('position', ['level', 'field', 'name'])

LEVEL = rule(
    caseless_pipeline([
        'junior', 'middle', 'senior', 'lead', 'chief', 'head', 'team lead',
        "старший", "младший", "руководитель направления"
    ]).interpretation(Position.level))

# TODO: нужно учесть жаргонные варианты (датасаентолог, датасатанист и т.д.) Скорее всего, придется парсить регулярками
NAME = rule(
    or_(
        caseless_pipeline([
            'data scientist', 'data engineer', 'engineer', 'analyst',
            'data analyst', 'data manager', 'scientist', 'researcher',
            "developer", "intern"
        ]), rule(dictionary(['DS', 'DE']), is_capitalized()),
        morph_pipeline(["аналитик", "разработчик",
                        "стажер"])).interpretation(Position.name.inflected()))

FIELD = rule(
    caseless_pipeline([
        'ML', 'DL', 'CV', 'computer vision', 'NLP', 'bi', 'machine learning',
        'deep learning', 'software', 'research', 'big data', 'python', 'c++',
        "scala", "java", 'ios', "android", 'devops', "backend", 'frontend'
    ]).interpretation(Position.field))

HEAD = rule(
    caseless('head').interpretation(Position.level), eq('of'),
    caseless_pipeline(['analytics', 'predictive analytics',
                       'data science']).interpretation(Position.field))
Ejemplo n.º 2
0
IN_MAYBE_FIRST = dictionary(set(load_dict('maybe_first.txt')))
IN_LAST = dictionary(set(load_dict('last.txt')))
###

Name = fact('Name', ['first', 'middle', 'last', 'nick'])

################# UNMODIFIED NATASHA #################
gnc = gnc_relation()

########
#
#   FIRST
#
########

TITLE = is_capitalized()

NOUN = gram('NOUN')
NAME_CRF = tag('I')

ABBR = gram('Abbr')
SURN = gram('Surn')
NAME = and_(gram('Name'), not_(ABBR))
PATR = and_(gram('Patr'), not_(ABBR))

FIRST = and_(NAME_CRF,
             or_(NAME, IN_MAYBE_FIRST,
                 IN_FIRST)).interpretation(Name.first.inflected()).match(gnc)

FIRST_ABBR = and_(ABBR, TITLE).interpretation(Name.first).match(gnc)
            documents.append(filename)
    return documents


documents = GetDocuments()
path = baseDir + '\\' + documents[0]
print(path)
document = Document(path)

from yargy import Parser, rule, and_
from yargy.predicates import gram, is_capitalized, dictionary

Name = rule(
    and_(
        gram('ADJF'),
        or_(is_capitalized(), is_upper()
            )  # http://pymorphy2.readthedocs.io/en/latest/user/grammemes.html
    ),
    gram('ADJF').optional().repeatable(),
    dictionary({'институт', 'кафедра', 'университет'}))

Name1 = rule(
    dictionary({'институт', 'кафедра', 'университет'}),
    gram('ADJF'),
    gram('ADJF').optional().repeatable(),
    gram('NOUN'),
)
parser = Parser(Name)
# parser = Parser(Name1)

for table in document.tables:
    '1.3. Планируемые результаты обучения по дисциплине ',
    'Перечень планируемых результатов обучения, соотнесенных с планируемыми результатами освоения образовательной программы',
    '\nПеречень планируемых результатов обучения, соотнесенных с планируемыми результатами освоения образовательной программы',
    '1.3. Перечень планируемых результатов обучения, соотнесенных '
]

from yargy import Parser, rule, and_, or_
from yargy.predicates import gram, is_capitalized, dictionary, is_upper, length_eq, is_title
from docx import Document
from docx.shared import Inches
import os, subprocess

baseDir = r'C:\Users\Катя\Desktop\рпд'

isResults = rule(
    and_(dictionary({'Знать', 'Уметь', 'Владеть'}), is_capitalized()))
result_rule = Parser(isResults)

IsCompetitionsAndResults = rule(dictionary({'результат'}))
table_rule = Parser(IsCompetitionsAndResults)


def GetDocuments():
    documents = []
    for filename in os.listdir(baseDir):
        if filename.endswith('.docx'):
            documents.append(filename)
    return documents


def GetIndexPart(list_header_result):
Ejemplo n.º 5
0
        rule(normalized('имя')),
        rule(caseless('им'), eq('.').optional()),
    ),
    or_(
        NAME_,
        PERSON_,
    ),
).interpretation(Organisation.name)

LATIN = rule(
    gram('OrganisationType'),
    or_(
        rule(
            and_(
                gram('LATN'),
                is_capitalized(),
            )
        ),
        rule(
            gram('LATN'),
            in_({'&', '/', '.'}),
            gram('LATN'),
        )
    ).repeatable()
).interpretation(Organisation.name)

KNOWN = rule(
    gram('Orgn'),
    GENT_GROUP,
).interpretation(Organisation.name)
Ejemplo n.º 6
0
IN_FIRST = dictionary(FIRST_DICT)
IN_MAYBE_FIRST = dictionary(MAYBE_FIRST_DICT)
IN_LAST = dictionary(LAST_DICT)

gnc = gnc_relation()


########
#
#   FIRST
#
########


TITLE = is_capitalized()

NOUN = gram('NOUN')
NAME_CRF = tag('I')

ABBR = gram('Abbr')
SURN = gram('Surn')
NAME = and_(
    gram('Name'),
    not_(ABBR)
)
PATR = and_(
    gram('Patr'),
    not_(ABBR)
)
Ejemplo n.º 7
0
])

parser = Parser(RULE)
text = 'Видео файл на dvd-диске'
for match in parser.findall(text):
    print([_.value for _ in match.tokens])

from yargy import Parser, rule, and_
from yargy.predicates import gram, is_capitalized, dictionary


GEO = rule(
    and_(
        gram('ADJF'),  # так помечается прилагательное, остальные пометки описаны в
                       # http://pymorphy2.readthedocs.io/en/latest/user/grammemes.html
        is_capitalized()
    ),
    gram('ADJF').optional().repeatable(),
    dictionary({
        'федерация',
        'республика'
    })
)


parser = Parser(GEO)
text = '''
В Чеченской республике на день рождения ...
Донецкая народная республика провозгласила ...
Башня Федерация — одна из самых высоких ...
'''
Ejemplo n.º 8
0
##########
#
#  COMPONENTS
#
###########

IS_FIRST = dictionary(FIRST_DICT)

MAYBE_FIRST = or_(
    and_(
        gram('Name'),
        not_(gram('Abbr'))  # А. Леонидов
    ),
    dictionary(MAYBE_FIRST_DICT))

TITLE_FIRST = and_(or_(IS_FIRST, MAYBE_FIRST), is_capitalized())

TITLE_FIRST_ABBR = and_(length_eq(1), is_capitalized())

TITLE_MIDDLE = and_(
    gram('Patr'),
    not_(gram('Abbr')),  # Фил О’Рейли -> "О" is Patr
    is_capitalized())

TITLE_MIDDLE_ABBR = and_(length_eq(1), is_capitalized())

IS_LAST = dictionary(LAST_DICT)

MAYBE_LAST = or_(gram('Surn'), dictionary(MAYBE_LAST_DICT))

TITLE_LAST = and_(or_(IS_LAST, MAYBE_LAST), is_capitalized())
Ejemplo n.º 9
0
    """
    def __call__(self, token):
        return len(token.value) > self.value


Lector = fact('Lector', ['name', 'degree'])

Name = fact(
    'Name',
    [attribute('first', ''),
     attribute('middle', ''),
     attribute('last', '')])

DOT = eq('.')

LAST = and_(type('RU'), is_capitalized(),
            length_grt(1)).interpretation(Name.last.custom(str.capitalize))

FIRST = and_(gram('Name'),
             length_grt(1)).interpretation(Name.first.custom(str.capitalize))

MIDDLE = and_(gram('Patr'),
              length_grt(1)).interpretation(Name.middle.custom(str.capitalize))
ABBR = and_(length_eq(1), is_capitalized())

FIRST_ABBR = ABBR.interpretation(Name.first.custom(str.upper))

MIDDLE_ABBR = ABBR.interpretation(Name.middle.custom(str.upper))

unsubstantial = {'Бен Режеб Т.Б.К.'}
Ejemplo n.º 10
0
        rule(normalized('имя')),
        rule(caseless('им'), eq('.').optional()),
    ),
    or_(
        NAME,
        PERSON,
    ),
)

LATIN = rule(
    TYPE,
    or_(
        rule(
            and_(
                type('LATIN'),
                is_capitalized(),
            )
        ),
        rule(
            type('LATIN'),
            in_({'&', '/', '.'}),
            type('LATIN'),
        )
    ).repeatable()
)

KNOWN = rule(
    gram('Orgn'),
    GENT_GROUP,
)