You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

54 lines
1.8 KiB

## based on https://explosion.ai/blog/german-model
'''
Wolfgang Seeker
Wolfgang is a computational linguist from Germany.
He is fascinated with the complexity and variety of human language,
and spent his PhD looking for ways to make NLP work well with any
kind of language in the world.
'''
import spacy
sentence1 = u'Ich bin ein Berliner'
sentence2 = u'Menschen, die du mal als Vampire tituliertest, investieren gerne, wenn sie den CEO einsetzen: meinem besten Freund wurden da Flausen in den Kopf gesetzt.'
sentence3 = u'Das demokratische Modell wird in Frage gestellt. Mir würde es die Sache erleichtern, wenn ich dort ein funktionierendes Modell etwas spezifizieren kann.'
sentence4 = u'Telekom oder nicht? Wir glauben nicht ^^'
sentence5 = u'Ich bin vom 1. April bis 6. April in Frankfurt. Falls du immer noch unter Druck arbeitest, nimm dies als reinen Belustigungsversuch. Würde mich freuen wenn es dann klappt. '
nlp = spacy.load('de')
doc = nlp(sentence1)
#for word in doc:
#print(word.orth_, word.pos_)
print('(sb: subject, nk: noun kernel, pd: predicate)')
for word in doc:
print(word , word.tag_)
print(word.pos_ , word)
print(word.orth_ ,'<--', word.dep_,'--', word.head.orth_)
'''
# show universal pos tags
print(' '.join('{word}/{tag}'.format(word=t.orth_, tag=t.pos_) for t in doc))
# output: Ich/PRON bin/AUX ein/DET Berliner/NOUN ./PUNCT
# show German specific pos tags (STTS)
print(' '.join('{word}/{tag}'.format(word.orth_, tag.tag_) for t in doc))
# output: Ich/PPER bin/VAFIN ein/ART Berliner/NN ./$.
# show dependency arcs
print('\n'.join('{child:<8} <{label:-^7} {head}'.format(child=t.orth_, label=t.dep_, head=t.head.orth_) for t in doc))
# output: (sb: subject, nk: noun kernel, pd: predicate)
# Ich <--sb--- bin
# bin <-ROOT-- bin
# ein <--nk--- Berliner
# Berliner <--pd--- bin
# . <-punct- bin
'''