Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR_1_Zhordaniya.md #25

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

PR_1_Zhordaniya.md #25

wants to merge 14 commits into from

Conversation

tamriq
Copy link

@tamriq tamriq commented Nov 3, 2018

Pragmatic Segmenter - сегментатор, работающий на правилах. Мне было трудно заставить его наконец работать, но когда у меня получилось, я была приятно удивлена.
Он правильно нашел ВСЕ предложения, но тут есть нюансы, о которых необходимо упомянуть. Например:

  • Anarchist historian George Woodcock reports: "The annual Congress of the International had not taken place in 1870 owing to the outbreak of the Paris Commune, and in 1871 the General Council called only a special conference in London. One delegate was able to attend from Spain and none from Italy, while a technical excuse – that they had split away from the Fédération Romande – was used to avoid inviting Bakunin's Swiss supporters. Thus only a tiny minority of anarchists was present, and the General Council's resolutions passed almost unanimously. Most of them were clearly directed against Bakunin and his followers".
    Сегментатор не размечал предложения, находящиеся внутри цитаты, как отдельные. Насколько я понимаю, вопрос о том, как стоит сегментатору поступать в таких ситуациях, является открытым, но я для себя решила, что такое поведение - верное.
    Также он отлично справился с сокращениями, аббревиатурами и другими уловками пунктуации. Пример:
  • In Latin America in particular, "anarchists quickly became active in organising craft and industrial workers throughout South and Central America, and until the early 1920s most of the trade unions in Mexico, Brazil, Peru, Chile, and Argentina were anarcho-syndicalist in general outlook; the prestige of the Spanish C.N.T. as a revolutionary organisation was undoubtedly to a great extent responsible for this situation. The largest and most militant of these organisations was the Federación Obrera Regional Argentina [... it grew quickly to a membership of nearly a quarter of a million, which dwarfed the rival socialdemocratic unions".
    Еще пример:
  • The word "" is composed from the word "anarchy" and the suffix -ism, themselves derived respectively from the Greek , i.e. "anarchy" (from , "anarchos", meaning "one without rulers"; from the privative prefix ἀν- ("an-", i.e. "without") and , "archos", i.e. "leader", "ruler"; (cf. "archon" or , "arkhē", i.e. "authority", "sovereignty", "realm", "magistracy")) and the suffix or ("-ismos", "-isma", from the verbal infinitive suffix , "-izein").

Результат: 100%

Nltk punkt - я использовала уже натренированный сегментатор для английского. К сожалению, он ошибся везде, где можно было это сделать. Разбивает предложения внутри цитат, не справляется с сокращениями и аббревиатурами.
Насчитал мне на шесть предложений больше, чем было. На зато более прост в использовании, чем Pragmatic Segmenter, ха-ха ;D

Вот его версии тех предложений, что я уже приводила выше:

  • In Latin America in particular, "anarchists quickly became active in organising craft and industrial workers throughout South and Central America, and until the early 1920s most of the trade unions in Mexico, Brazil, Peru, Chile, and Argentina were anarcho-syndicalist in general outlook; the prestige of the Spanish C.N.T.

as a revolutionary organisation was undoubtedly to a great extent responsible for this situation.

  • The word "" is composed from the word "anarchy" and the suffix -ism, themselves derived respectively from the Greek , i.e.
    "anarchy" (from , "anarchos", meaning "one without rulers"; from the privative prefix ἀν- ("an-", i.e.
    "without") and , "archos", i.e.
    "leader", "ruler"; (cf.
    "archon" or , "arkhē", i.e.
    "authority", "sovereignty", "realm", "magistracy")) and the suffix or ("-ismos", "-isma", from the verbal infinitive suffix , "-izein").

  • Anarchist historian George Woodcock reports: "The annual Congress of the International had not taken place in 1870 owing to the outbreak of the Paris Commune, and in 1871 the General Council called only a special conference in London.

One delegate was able to attend from Spain and none from Italy, while a technical excuse – that they had split away from the Fédération Romande – was used to avoid inviting Bakunin's Swiss supporters.

Thus only a tiny minority of anarchists was present, and the General Council's resolutions passed almost unanimously.
Most of them were clearly directed against Bakunin and his followers".

Результат: 84%

@tamriq
Copy link
Author

tamriq commented Nov 3, 2018

maxmatch

  1. Словарь из файла я извлекла с помощью команды sed '/^#/'d | cut -f2 -d' '

  2. С максматчем было сложнее! Так как я новичок в программировании, я решила выбрать самый простой и очевидный скрипт. Рекурсивная функция получает на вход:

  • предложения для обработки
  • словарь токенов.
    С помощью шага -1 с конца предложения каждый цикл отсчитывает один символ, после чего срез [от начала предложения : до символа] сравнивается с токенами из словаря. Найденное слово возвращается, после чего поиск продолжается по срезу [последний токен слова+1 :] Если слово не найдено в словаре, возвращается односимвольное слово.
    Я очень хотела сделать код удобным в использовании, поэтому пыталась сделать:
    if name == 'main':
    sents = sys.argv[1]
    dictionary = sys.argv[2]
    maxmatch(sents, dictionary)

Но...У меня не получилось, поэтому инструкция по использованию выглядит примерно так:

  • Открыть список предложений и словарь в питоне
  • Запустить функцию с аргументами (предложения, словарь)
  • ???????
  • PROFIT!!!!
  1. WER: 7.39%
    Стоит признаться - WER тестировал не все мои данные, а только первые 20 предложений. К сожалению, мощность моего компьютера не могла мне позволить обработать все

@tamriq
Copy link
Author

tamriq commented Nov 3, 2018

def maxmatch(sents, dictionary):
    if not sents:
        return []
    for i in range(len(sents)-1, -1, -1):
        word = sents[:i+1]
        remains = sents[i+1:]
        if word in dictionary:
            return [word] + maxmatch(remains, dictionary)            
        else:
            word = sents[0]
            remains = sents[1:]
            return [word] + maxmatch(remains, dictionary)

@tamriq tamriq changed the title segmentation.md PR_1_Zhordaniya.md Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant