Exemplo n.º 1
0
def fix_punct(conllu_string):
	doc = Document()
	doc.from_conllu_string(conllu_string)
	fixpunct_block = FixPunct()
	fixpunct_block.process_document(doc)
	output_string = doc.to_conllu_string()
	return output_string
Exemplo n.º 2
0
def fix_punct(conllu_string):
	doc = Document()
	doc.from_conllu_string(conllu_string)
	fixpunct_block = FixPunct()
	fixpunct_block.process_document(doc)
	output_string = doc.to_conllu_string()
	output_string = re.sub(r'# sent_id = [0-9]+\n',r'',output_string)  # remove udapi sent_id
	return output_string
Exemplo n.º 3
0
def fix_punct(conllu_string):
	# Protect possessive apostrophe from being treated as punctuation
	conllu_string = re.sub(r"\t'\t([^\t\n]+\tPART\tPOS)", r'\t&udapi_apos;\t\1', conllu_string, flags=re.MULTILINE)  # remove udapi sent_id
	doc = Document()
	doc.from_conllu_string(conllu_string)
	fixpunct_block = FixPunct()
	fixpunct_block.process_document(doc)
	output_string = doc.to_conllu_string()
	output_string = output_string.replace('&udapi_apos;',"'")
	output_string = re.sub(r'# sent_id = [0-9]+\n',r'',output_string)  # remove udapi sent_id
	return output_string
Exemplo n.º 4
0
def fix_punct(conllu_string):
    conllu_string = re.sub(r"\t'\t([^\t\n]+\tPART\tPOS)",
                           r'\t&udapi_apos;\t\1',
                           conllu_string,
                           flags=re.MULTILINE)
    conllu_string = re.sub(
        r'\t"\t([^\t\n]+\t[^\t\n]+\t[^\t\n]+\t[^\t\n]+\t[^\t\n]+\t[^p])',
        r'\t&udapi_quot;\t\1',
        conllu_string,
        flags=re.MULTILINE)
    doc = UdapiDocument()
    doc.from_conllu_string(conllu_string)
    fixpunct_block = FixPunct()
    fixpunct_block.process_document(doc)
    output_string = doc.to_conllu_string()
    output_string = output_string.replace('&udapi_apos;',
                                          "'").replace('&udapi_quot;', '"')
    output_string = re.sub(r'# sent_id = [0-9]+\n', r'',
                           output_string)  # remove udapi sent_id
    return output_string
Exemplo n.º 5
0
def main():
    doc = Document()
    doc.from_conllu_string(conllu_string1)
    tree = doc.bundles[0].get_tree()
    nodes = tree.descendants
    writer = ConlluWriter()

    # Shifter
    shifter = ShiftArtificials()
    shifter.apply_on_document(doc)

    # writer.apply_on_document(doc)

    # Converter
    converter = SubTreeConverter(with_enhanced=True)
    converter.apply_on_document(doc)

    print(len(tree.empty_nodes))

    # Writer
    writer.apply_on_document(doc)
Exemplo n.º 6
0
 def from_connlu(conllu):
     doc = Document()
     doc.from_conllu_string(conllu)
     return doc