Java Stanford NLP: 음성 라벨의 일부?
Stanford NLP의 데모는 다음과 같습니다.
Colorless/JJ green/JJ ideas/NNS sleep/VBP furiously/RB ./.
연설의 일부?공식 리스트를 찾을 수 없습니다.탠포 、 ( ( 、 니 ( 、( (? ( ( )가 뭐죠?)JJ
★★★★★★★★★★★★★★★★★★?
예를 명사를 가 안 붙는지 하는 등의 ..contains('N')
★★★★★★★★★★★★★★★★★★★★★★★★★★★특정 부분을 프로그래밍 방식으로 검색할 수 있는 더 좋은 방법이 있을까요?
펜 트리뱅크 프로젝트요Part-of-Speech 태그 ps를 확인합니다.
JJ는 형용사예요.NNS는 명사, 복수입니다.VBP는 동사 현재 시제입니다.RB는 부사입니다.
그건 영어용이에요.중국인들은 '펜차이나 트리뱅크'라고 하죠.독일에서는 NEGRA 말뭉치입니다
- CC Coordining 접속사
- CD 카디널 번호
- DT 결정자
- EX 거기에 존재하다
- FW 외래어
- IN 사전 배치 또는 종속 연결사
- JJ 형용사
- JJR 형용사, 비교
- JJS 형용사, 최상급
- LS 목록 항목 마커
- MD모달
- NN 명사, 단수 또는 질량
- NNS 명사, 복수
- NNP 고유명사, 단수
- NNPS 고유명사, 복수
- PDT 사전 결정자
- POS 소유형 엔딩
- PRP 인칭 대명사
- PRP$ 소유 대명사
- RB부사
- RBR 부사, 비교
- RBS 부사, 최상급
- RP 파티클
- SYM 기호
- 토토
- UH 삽입
- VB 동사, 기본 형식
- VBD 동사, 과거형
- VBG 동사, 동사 또는 현재 분사
- VBN 동사, 과거 분사
- VBP 동사, 3인칭 이외의 단수 존재
- VBZ 동사, 3인칭 단수 선물
- WDT Whdeterm결정자
- WP Whpronpronoun
- WP$ 소유권 부여
- WRB Whad부사
Explanation of each tag from the documentation :
CC: conjunction, coordinating
& 'n and both but either et for less minus neither nor or plus so
therefore times v. versus vs. whether yet
CD: numeral, cardinal
mid-1890 nine-thirty forty-two one-tenth ten million 0.5 one forty-
seven 1987 twenty '79 zero two 78-degrees eighty-four IX '60s .025
fifteen 271,124 dozen quintillion DM2,000 ...
DT: determiner
all an another any both del each either every half la many much nary
neither no some such that the them these this those
EX: existential there
there
FW: foreign word
gemeinschaft hund ich jeux habeas Haementeria Herr K'ang-si vous
lutihaw alai je jour objets salutaris fille quibusdam pas trop Monte
terram fiche oui corporis ...
IN: preposition or conjunction, subordinating
astride among uppon whether out inside pro despite on by throughout
below within for towards near behind atop around if like until below
next into if beside ...
JJ: adjective or numeral, ordinal
third ill-mannered pre-war regrettable oiled calamitous first separable
ectoplasmic battery-powered participatory fourth still-to-be-named
multilingual multi-disciplinary ...
JJR: adjective, comparative
bleaker braver breezier briefer brighter brisker broader bumper busier
calmer cheaper choosier cleaner clearer closer colder commoner costlier
cozier creamier crunchier cuter ...
JJS: adjective, superlative
calmest cheapest choicest classiest cleanest clearest closest commonest
corniest costliest crassest creepiest crudest cutest darkest deadliest
dearest deepest densest dinkiest ...
LS: list item marker
A A. B B. C C. D E F First G H I J K One SP-44001 SP-44002 SP-44005
SP-44007 Second Third Three Two * a b c d first five four one six three
two
MD: modal auxiliary
can cannot could couldn't dare may might must need ought shall should
shouldn't will would
NN: noun, common, singular or mass
common-carrier cabbage knuckle-duster Casino afghan shed thermostat
investment slide humour falloff slick wind hyena override subhumanity
machinist ...
NNS: noun, common, plural
undergraduates scotches bric-a-brac products bodyguards facets coasts
divestitures storehouses designs clubs fragrances averages
subjectivists apprehensions muses factory-jobs ...
NNP: noun, proper, singular
Motown Venneboerger Czestochwa Ranzer Conchita Trumplane Christos
Oceanside Escobar Kreisler Sawyer Cougar Yvette Ervin ODI Darryl CTCA
Shannon A.K.C. Meltex Liverpool ...
NNPS: noun, proper, plural
Americans Americas Amharas Amityvilles Amusements Anarcho-Syndicalists
Andalusians Andes Andruses Angels Animals Anthony Antilles Antiques
Apache Apaches Apocrypha ...
PDT: pre-determiner
all both half many quite such sure this
POS: genitive marker
' 's
PRP: pronoun, personal
hers herself him himself hisself it itself me myself one oneself ours
ourselves ownself self she thee theirs them themselves they thou thy us
PRP$: pronoun, possessive
her his mine my our ours their thy your
RB: adverb
occasionally unabatingly maddeningly adventurously professedly
stirringly prominently technologically magisterially predominately
swiftly fiscally pitilessly ...
RBR: adverb, comparative
further gloomier grander graver greater grimmer harder harsher
healthier heavier higher however larger later leaner lengthier less-
perfectly lesser lonelier longer louder lower more ...
RBS: adverb, superlative
best biggest bluntest earliest farthest first furthest hardest
heartiest highest largest least less most nearest second tightest worst
RP: particle
aboard about across along apart around aside at away back before behind
by crop down ever fast for forth from go high i.e. in into just later
low more off on open out over per pie raising start teeth that through
under unto up up-pp upon whole with you
SYM: symbol
% & ' '' ''. ) ). * + ,. < = > @ A[fj] U.S U.S.S.R * ** ***
TO: "to" as preposition or infinitive marker
to
UH: interjection
Goodbye Goody Gosh Wow Jeepers Jee-sus Hubba Hey Kee-reist Oops amen
huh howdy uh dammit whammo shucks heck anyways whodunnit honey golly
man baby diddle hush sonuvabitch ...
VB: verb, base form
ask assemble assess assign assume atone attention avoid bake balkanize
bank begin behold believe bend benefit bevel beware bless boil bomb
boost brace break bring broil brush build ...
VBD: verb, past tense
dipped pleaded swiped regummed soaked tidied convened halted registered
cushioned exacted snubbed strode aimed adopted belied figgered
speculated wore appreciated contemplated ...
VBG: verb, present participle or gerund
telegraphing stirring focusing angering judging stalling lactating
hankerin' alleging veering capping approaching traveling besieging
encrypting interrupting erasing wincing ...
VBN: verb, past participle
multihulled dilapidated aerosolized chaired languished panelized used
experimented flourished imitated reunifed factored condensed sheared
unsettled primed dubbed desired ...
VBP: verb, present tense, not 3rd person singular
predominate wrap resort sue twist spill cure lengthen brush terminate
appear tend stray glisten obtain comprise detest tease attract
emphasize mold postpone sever return wag ...
VBZ: verb, present tense, 3rd person singular
bases reconstructs marks mixes displeases seals carps weaves snatches
slumps stretches authorizes smolders pictures emerges stockpiles
seduces fizzes uses bolsters slaps speaks pleads ...
WDT: WH-determiner
that what whatever which whichever
WP: WH-pronoun
that what whatever whatsoever which who whom whosoever
WP$: WH-pronoun, possessive
whose
WRB: Wh-adverb
how however whence whenever where whereby whereever wherein whereof why
위의 승인된 답변에 다음 정보가 누락되었습니다.
구두점 태그도 9개가 정의되어 있습니다(일부 참조에는 기재되어 있지 않습니다).다음과 같습니다.
- #
- $
- " (모든 형식의 마감 견적서에 사용)
- (모든 형식의 오프닝 괄호에 사용)
- ) (모든 형식의 닫힘 괄호에 사용)
- ,
- . (모든 문장 끝 구두점에 사용)
- : (콜론, 세미콜론 및 줄임표에 사용)
- " (모든 형식의 첫 번째 인용문에 사용)
다음은 Pen Treebank의 태그 목록입니다(완성을 위해 여기에 게시).
http://www.surdeanu.info/mihai/teaching/ista555-fall13/readings/PennTreebankConstituents.html
또한 절 및 구 레벨에 대한 태그도 포함됩니다.
절 수준
- S
- SBAR
- SBARQ
- SINV
- SQ
구 수준
- ADJP
- ADVP
- CONJP
- FRAG
- INTJ
- LST
- NAC
- NP
- NX
- PP
- PRN
- PRT
- QP
- RRC
- UCP
- VP
- WHADJP
- WHAVP
- WHNP
- WHPP
- X
(링크 내 제약사항)
코드화:
/**
* Represents the English parts-of-speech, encoded using the
* de facto <a href="http://www.cis.upenn.edu/~treebank/">Penn Treebank
* Project</a> standard.
*
* @see <a href="ftp://ftp.cis.upenn.edu/pub/treebank/doc/tagguide.ps.gz">Penn Treebank Specification</a>
*/
public enum PartOfSpeech {
ADJECTIVE( "JJ" ),
ADJECTIVE_COMPARATIVE( ADJECTIVE + "R" ),
ADJECTIVE_SUPERLATIVE( ADJECTIVE + "S" ),
/* This category includes most words that end in -ly as well as degree
* words like quite, too and very, posthead modi ers like enough and
* indeed (as in good enough, very well indeed), and negative markers like
* not, n't and never.
*/
ADVERB( "RB" ),
/* Adverbs with the comparative ending -er but without a strictly comparative
* meaning, like <i>later</i> in <i>We can always come by later</i>, should
* simply be tagged as RB.
*/
ADVERB_COMPARATIVE( ADVERB + "R" ),
ADVERB_SUPERLATIVE( ADVERB + "S" ),
/* This category includes how, where, why, etc.
*/
ADVERB_WH( "W" + ADVERB ),
/* This category includes and, but, nor, or, yet (as in Y et it's cheap,
* cheap yet good), as well as the mathematical operators plus, minus, less,
* times (in the sense of "multiplied by") and over (in the sense of "divided
* by"), when they are spelled out. <i>For</i> in the sense of "because" is
* a coordinating conjunction (CC) rather than a subordinating conjunction.
*/
CONJUNCTION_COORDINATING( "CC" ),
CONJUNCTION_SUBORDINATING( "IN" ),
CARDINAL_NUMBER( "CD" ),
DETERMINER( "DT" ),
/* This category includes which, as well as that when it is used as a
* relative pronoun.
*/
DETERMINER_WH( "W" + DETERMINER ),
EXISTENTIAL_THERE( "EX" ),
FOREIGN_WORD( "FW" ),
LIST_ITEM_MARKER( "LS" ),
NOUN( "NN" ),
NOUN_PLURAL( NOUN + "S" ),
NOUN_PROPER_SINGULAR( NOUN + "P" ),
NOUN_PROPER_PLURAL( NOUN + "PS" ),
PREDETERMINER( "PDT" ),
POSSESSIVE_ENDING( "POS" ),
PRONOUN_PERSONAL( "PRP" ),
PRONOUN_POSSESSIVE( "PRP$" ),
/* This category includes the wh-word whose.
*/
PRONOUN_POSSESSIVE_WH( "WP$" ),
/* This category includes what, who and whom.
*/
PRONOUN_WH( "WP" ),
PARTICLE( "RP" ),
/* This tag should be used for mathematical, scientific and technical symbols
* or expressions that aren't English words. It should not used for any and
* all technical expressions. For instance, the names of chemicals, units of
* measurements (including abbreviations thereof) and the like should be
* tagged as nouns.
*/
SYMBOL( "SYM" ),
TO( "TO" ),
/* This category includes my (as in M y, what a gorgeous day), oh, please,
* see (as in See, it's like this), uh, well and yes, among others.
*/
INTERJECTION( "UH" ),
VERB( "VB" ),
VERB_PAST_TENSE( VERB + "D" ),
VERB_PARTICIPLE_PRESENT( VERB + "G" ),
VERB_PARTICIPLE_PAST( VERB + "N" ),
VERB_SINGULAR_PRESENT_NONTHIRD_PERSON( VERB + "P" ),
VERB_SINGULAR_PRESENT_THIRD_PERSON( VERB + "Z" ),
/* This category includes all verbs that don't take an -s ending in the
* third person singular present: can, could, (dare), may, might, must,
* ought, shall, should, will, would.
*/
VERB_MODAL( "MD" ),
/* Stanford.
*/
SENTENCE_TERMINATOR( "." );
private final String tag;
private PartOfSpeech( String tag ) {
this.tag = tag;
}
/**
* Returns the encoding for this part-of-speech.
*
* @return A string representing a Penn Treebank encoding for an English
* part-of-speech.
*/
public String toString() {
return getTag();
}
protected String getTag() {
return this.tag;
}
public static PartOfSpeech get( String value ) {
for( PartOfSpeech v : values() ) {
if( value.equals( v.getTag() ) ) {
return v;
}
}
throw new IllegalArgumentException( "Unknown part of speech: '" + value + "'." );
}
}
여기에 전체 목록을 제공하고 참조 링크도 제공합니다.
1. CC Coordinating conjunction
2. CD Cardinal number
3. DT Determiner
4. EX Existential there
5. FW Foreign word
6. IN Preposition or subordinating conjunction
7. JJ Adjective
8. JJR Adjective, comparative
9. JJS Adjective, superlative
10. LS List item marker
11. MD Modal
12. NN Noun, singular or mass
13. NNS Noun, plural
14. NNP Proper noun, singular
15. NNPS Proper noun, plural
16. PDT Predeterminer
17. POS Possessive ending
18. PRP Personal pronoun
19. PRP$ Possessive pronoun
20. RB Adverb
21. RBR Adverb, comparative
22. RBS Adverb, superlative
23. RP Particle
24. SYM Symbol
25. TO to
26. UH Interjection
27. VB Verb, base form
28. VBD Verb, past tense
29. VBG Verb, gerund or present participle
30. VBN Verb, past participle
31. VBP Verb, non-3rd person singular present
32. VBZ Verb, 3rd person singular present
33. WDT Wh-determiner
34. WP Wh-pronoun
35. WP$ Possessive wh-pronoun
36. WRB Wh-adverb
여기서 Parts of Speech 태그의 전체 목록을 찾을 수 있습니다.
특정 POS(예: Nause) 태그가 달린 단어/청크를 찾는 두 번째 질문에 대해, 다음은 여러분이 따를 수 있는 샘플 코드입니다.
public static void main(String[] args) {
Properties properties = new Properties();
properties.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse");
StanfordCoreNLP pipeline = new StanfordCoreNLP(properties);
String input = "Colorless green ideas sleep furiously.";
Annotation annotation = pipeline.process(input);
List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
List<String> output = new ArrayList<>();
String regex = "([{pos:/NN|NNS|NNP/}])"; //Noun
for (CoreMap sentence : sentences) {
List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
TokenSequencePattern pattern = TokenSequencePattern.compile(regex);
TokenSequenceMatcher matcher = pattern.getMatcher(tokens);
while (matcher.find()) {
output.add(matcher.group());
}
}
System.out.println("Input: "+input);
System.out.println("Output: "+output);
}
출력은 다음과 같습니다.
Input: Colorless green ideas sleep furiously.
Output: [ideas]
Stanford CoreNLP 태그 (기타 언어용) : 프랑스어, 스페인어, 독일어...
디폴트 모델인 영어 파서를 사용하고 있군요.파서는 다른 언어(프랑스어, 스페인어, 독일어 등)에 사용할 수 있습니다.또, 토큰라이저와 음성 태그의 일부는 언어 마다 다릅니다.이를 수행하려면 Maven과 같은 빌더를 사용하여 해당 언어의 특정 모델을 다운로드한 후 사용할 모델을 설정해야 합니다.여기에 더 많은 정보가 있습니다.
언어별 태그 목록은 다음과 같습니다.
- 스페인어용 스탠포드 CoreNLP POS 태그
- Stanford CoreNLP POS 태그(독일어판)는 Stuttgart-Tübingen 태그 세트(STTS)를 사용합니다.
- Stanford CoreNLP POS 태그(프랑스어판)는 다음 태그를 사용합니다.
프랑스어 태그:
프랑스어 음성 태그의 일부
A (adjective)
Adv (adverb)
CC (coordinating conjunction)
Cl (weak clitic pronoun)
CS (subordinating conjunction)
D (determiner)
ET (foreign word)
I (interjection)
NC (common noun)
NP (proper noun)
P (preposition)
PREF (prefix)
PRO (strong pronoun)
V (verb)
PONCT (punctuation mark)
프랑스어 구문 카테고리 태그:
AP (adjectival phrases)
AdP (adverbial phrases)
COORD (coordinated phrases)
NP (noun phrases)
PP (prepositional phrases)
VN (verbal nucleus)
VPinf (infinitive clauses)
VPpart (nonfinite clauses)
SENT (sentences)
Sint, Srel, Ssub (finite clauses)
프랑스어 구문 함수:
SUJ (subject)
OBJ (direct object)
ATS (predicative complement of a subject)
ATO (predicative complement of a direct object)
MOD (modifier or adjunct)
A-OBJ (indirect complement introduced by à)
DE-OBJ (indirect complement introduced by de)
P-OBJ (indirect complement introduced by another preposition)
스페이시에서는 매우 빨랐지만, 로우엔드 노트북에서는 다음과 같이 동작합니다.
import spacy
import time
start = time.time()
with open('d:/dictionary/e-store.txt') as f:
input = f.read()
word = 0
result = []
nlp = spacy.load("en_core_web_sm")
doc = nlp(input)
for token in doc:
if token.pos_ == "NOUN":
result.append(token.text)
word += 1
elapsed = time.time() - start
print("From", word, "words, there is", len(result), "NOUN found in", elapsed, "seconds")
몇 가지 시행에서의 출력:
From 3547 words, there is 913 NOUN found in 7.768507719039917 seconds
From 3547 words, there is 913 NOUN found in 7.408619403839111 seconds
From 3547 words, there is 913 NOUN found in 7.431427955627441 seconds
따라서 POS 태그 체크마다 루핑이 발생할 염려가 없다고 생각합니다.
특정 파이프라인을 비활성화했을 때 향상된 기능:
nlp = spacy.load("en_core_web_sm", disable = 'ner')
따라서 결과는 더 빠릅니다.
From 3547 words, there is 913 NOUN found in 6.212834596633911 seconds
From 3547 words, there is 913 NOUN found in 6.257707595825195 seconds
From 3547 words, there is 913 NOUN found in 6.371225833892822 seconds
언급URL : https://stackoverflow.com/questions/1833252/java-stanford-nlp-part-of-speech-labels
'sourcecode' 카테고리의 다른 글
v-for - VUE에서 어레이 항목을 제거하려면 인덱스를 하위 구성 요소에서 상위 구성 요소로 보냅니다.JS 2 (0) | 2022.08.28 |
---|---|
여기서 메인 0이 반환되지 않는 이유는 무엇입니까? (0) | 2022.08.28 |
라우터 매개 변수의 프로펠러 유형이 잘못되었습니다. 수에 문자열이 있어야 합니다. (0) | 2022.08.28 |
스택 트레이스를 문자열로 변환하려면 어떻게 해야 하나요? (0) | 2022.08.28 |
VUEJS-url에서 매개 변수를 제거하는 방법 (0) | 2022.08.28 |