<jupyter_start><jupyter_text>aux: auxiliary，非主要动词和助词，如BE,HAVE SHOULD/COULD等到    auxpass: passive auxiliary 被动词<jupyter_code>from sagas.nlu.corenlp_helper import CoreNlp, CoreNlpViz, get_nlp
ana=lambda sents: CoreNlpViz().analyse(sents, get_nlp('de'))
ana('Ich möchte, dass du ein Lehrer wirst.')
ana('Vielleicht wird er ein guter Lehrer.')
ana('Deine Stirn ist groß.')
ana('Was ist deine Position?')
from sagas.nlu.corenlp_parser import equals, get_children_list
import sagas

def get_word_features(word):
    # 'c' represent a chunk
    return ['c_{}_{}'.format(word.lemma, word.upos).lower()]

def get_aux_domain(sent, filters):
    rs = []    
    for word in filter(lambda w: w.upos == "AUX", sent.words):
        if word.governor==0:
            # if the aux word is root
            dc=word
        else:
            dc=sent.words[word.governor-1]
        print('℗', word.text, word.dependency_relation, word.governor, '☇' , dc.text)
        # print('\t', dc.index, dc.text, get_children_list(sent, dc))
        domains = []
        # 需要收集的是aux单词依赖的对象的关联集, 而不是aux单词自身的关联集
        for c in filter(lambda w: equals(w.governor, dc.index), sent.words):
            # print('\t', c.index, c.text, get_children_list(sent, c))
            domains.append((c.dependency_relation, c.index, c.text, 
                            get_children_list(sent, c), get_word_features(c)))
        rs.append({'aux': word.text, 'index': word.index, 'domains': domains})
    return rs

# sents='Was ist deine Position?'
# The parties are not tomorrow.
sents='Die Partys sind nicht morgen.'

nlp=get_nlp('de')
doc = nlp(sents)
sent = doc.sentences[0]
rs = get_aux_domain(sent, ['obl', 'nsubj:pass'])
for r in rs:
    df = sagas.to_df(r['domains'], ['rel', 'index', 'text', 'children', 'features'])
    display(df)
# data_y = json.dumps(r, indent=2, ensure_ascii=False)
# print(data_y)
def parse_sents(sents, lang='de'):
    nlp=get_nlp(lang)
    doc = nlp(sents)
    sent = doc.sentences[0]
    return sent
def display_rs(rs):
    for r in rs:
        df = sagas.to_df(r['domains'], ['rel', 'index', 'text', 'children', 'features'])
        display(df)
def get_subj(sent):
    rs = []    
    for word in filter(lambda w: w.dependency_relation.endswith('subj'), sent.words):    
        dc=sent.words[word.governor-1]
        print('℗', word.text, word.dependency_relation, word.governor, '☇' , dc.text)
        domains = []
        # 需要收集的是aux单词依赖的对象的关联集, 而不是aux单词自身的关联集
        for c in filter(lambda w: equals(w.governor, dc.index), sent.words):
            # print('\t', c.index, c.text, get_children_list(sent, c))
            domains.append((c.dependency_relation, c.index, c.text, 
                            get_children_list(sent, c), get_word_features(c)))
        rs.append({'type':'subj_domains', 'subj': word.text, 'index': word.index, 'domains': domains})
    return rs

rs=get_subj(parse_sents('Die Partys sind nicht morgen.'))
display_rs(rs)
ana('Wo ist die Anleitung?')
ana('Wir rennen durch die Felder.')
ana('Die Partys sind nicht morgen .')
ana('Welche Hobbys hast du ?')
def fix_sents(lang, text):
    if lang in ['de']:
        text=text.strip()
        if text[-1] not in ['!','?','.']:
            return '%s .'%text
        if text[-2]!=' ':
            return '%s %s'%(text[0:-1], text[-1])
    return text
print(fix_sents('de', 'Welche Hobbys hast du'))
print(fix_sents('de', 'Welche Hobbys hast du?'))
from sagas.nlu.corenlp_helper import LangDialect as dia
dia('de').ana('Welche Hobbys hast du ?')  # with word translation
dia('de').ana_s('Diese Liga ist die beste Liga, glaube ich.')
def a_func():
    return 1,2
a_list=[a_func(), a_func()]
a_list<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15830848468419625, 'fraction_numerical': 0.0035239902412577935, 'mean_word_length': 3.366863905325444, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '104677', 'license': 'Apache-2.0', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1389, 'n_words': 314, 'path': 'notebook/procs-de.ipynb', 'repo_name': 'samlet/stack', 'size': '3689'}