Biblioteca de tagger de parte do inglês em inglês; um porto rubi de língua :: pt :: tagger
Uma porta rubi de Perl Lingua :: pt :: tagger, um tagger com probabilidade baseado em corpus que atribui tags de POS ao texto em inglês com base em um dicionário de pesquisa e em um conjunto de valores de probabilidade. O tagger atribui tags apropriadas com base em probabilidades condicionais-examina a tag anterior para determinar a tag apropriada para a palavra atual. Palavras desconhecidas são classificadas de acordo com a morfologia das palavras ou podem ser definidas para serem tratadas como substantivos ou outras partes da fala. O tagger também extrai o maior número possível de frases de substantivos e substantivos, usando um conjunto de expressões regulares.
require 'engtagger'
# Create a parser object
tgr = EngTagger . new
# Sample text
text = "Alice chased the big fat cat."
# Add part-of-speech tags to text
tagged = tgr . add_tags ( text )
#=> "<nnp>Alice</nnp> <vbd>chased</vbd> <det>the</det> <jj>big</jj> <jj>fat</jj><nn>cat</nn> <pp>.</pp>"
# Get a list of all nouns and noun phrases with occurrence counts
word_list = tgr . get_words ( text )
#=> {"Alice"=>1, "cat"=>1, "fat cat"=>1, "big fat cat"=>1}
# Get a readable version of the tagged text
readable = tgr . get_readable ( text )
#=> "Alice/NNP chased/VBD the/DET big/JJ fat/JJ cat/NN ./PP"
# Get all nouns from a tagged output
nouns = tgr . get_nouns ( tagged )
#=> {"cat"=>1, "Alice"=>1}
# Get all proper nouns
proper = tgr . get_proper_nouns ( tagged )
#=> {"Alice"=>1}
# Get all past tense verbs
pt_verbs = tgr . get_past_tense_verbs ( tagged )
#=> {"chased"=>1}
# Get all the adjectives
adj = tgr . get_adjectives ( tagged )
#=> {"big"=>1, "fat"=>1}
# Get all noun phrases of any syntactic level
# (same as word_list but take a tagged input)
nps = tgr . get_noun_phrases ( tagged )
#=> {"Alice"=>1, "cat"=>1, "fat cat"=>1, "big fat cat"=>1} O conjunto de tags POS usadas aqui é uma versão modificada do Penn Treebank TagSet. Tags com caracteres não-letras foram redefinidas para funcionar melhor em nossas estruturas de dados. Além disso, a tag "determinante" (Det) foi alterada de 'dt', a fim de evitar confusão com a tag html, <DT> .
CC Conjunction, coordinating and, or
CD Adjective, cardinal number 3, fifteen
DET Determiner this, each, some
EX Pronoun, existential there there
FW Foreign words
IN Preposition / Conjunction for, of, although, that
JJ Adjective happy, bad
JJR Adjective, comparative happier, worse
JJS Adjective, superlative happiest, worst
LS Symbol, list item A, A.
MD Verb, modal can, could, 'll
NN Noun aircraft, data
NNP Noun, proper London, Michael
NNPS Noun, proper, plural Australians, Methodists
NNS Noun, plural women, books
PDT Determiner, prequalifier quite, all, half
POS Possessive 's, '
PRP Determiner, possessive second mine, yours
PRPS Determiner, possessive their, your
RB Adverb often, not, very, here
RBR Adverb, comparative faster
RBS Adverb, superlative fastest
RP Adverb, particle up, off, out
SYM Symbol *
TO Preposition to
UH Interjection oh, yes, mmm
VB Verb, infinitive take, live
VBD Verb, past tense took, lived
VBG Verb, gerund taking, living
VBN Verb, past/passive participle taken, lived
VBP Verb, base present form take, live
VBZ Verb, present 3SG -s form takes, lives
WDT Determiner, question which, whatever
WP Pronoun, question who, whoever
WPS Determiner, possessive & question whose
WRB Adverb, question when, how, however
PP Punctuation, sentence ender ., !, ?
PPC Punctuation, comma ,
PPD Punctuation, dollar sign $
PPL Punctuation, quotation mark left ``
PPR Punctuation, quotation mark right ''
PPS Punctuation, colon, semicolon, elipsis :, ..., -
LRB Punctuation, left bracket (, {, [
RRB Punctuation, right bracket ), }, ]
Abordagem recomendada (sem sudo):
Recomenda -se instalar o engtagger Gem no ambiente do seu usuário sem privilégios root. Isso garante permissões de arquivo adequadas e evita possíveis problemas. Você pode conseguir isso usando gerentes de versão Ruby como rbenv ou rvm para gerenciar suas versões e gemsets do Ruby.
Para instalar sem sudo , basta executar:
gem install engtaggerAbordagem alternativa (com sudo):
Se você precisar usar sudo para instalação, precisará ajustar as permissões de arquivo posteriormente para garantir a acessibilidade.
sudo : sudo gem install engtaggersudo chown -R $( whoami ) /Library/Ruby/Gems/2.6.0/gems/engtagger-0.4.1 Nota: O caminho acima assume que você está usando o Ruby versão 2.6.0. Se você estiver usando uma versão diferente, precisará modificar o caminho de acordo. Você pode encontrar sua versão Ruby executando ruby -v .
Problemas de permissão:
Se você encontrar erros "não pode carregar esse arquivo" após a instalação, pode ser devido a permissões de arquivo incorretas. Verifique se você seguiu as instruções para ajustar as permissões se você usou sudo durante a instalação.
Yoichiro hasebe (yohasebe [at] gmail.com)
Muito obrigado aos colaboradores listados na coluna certa desta página do Github.
Esta biblioteca Ruby é uma porta direta de Lingua :: pt :: Tagger disponível no CPAN. O crédito pela parte crucial de seu algoritmo/design, portanto, vai para Aaron Coburn, o autor da versão Perl original.
Esta biblioteca é distribuída pelo GPL. Consulte o arquivo de licença.