Skip to content

Commit

Permalink
Remove some deprecated methods from the conll method - will make it e…
Browse files Browse the repository at this point in the history
…asier to update other parts of the conll conversion
  • Loading branch information
AngledLuffa committed Oct 14, 2023
1 parent fe200d4 commit e01650f
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions stanza/utils/conll.py
Expand Up @@ -3,7 +3,6 @@
"""
import os
import io
import warnings
from zipfile import ZipFile

from stanza.models.common.doc import Document
Expand Down Expand Up @@ -113,37 +112,6 @@ def conll2doc(input_file=None, input_str=None, ignore_gapping=True, zip_file=Non
doc_dict, doc_comments = CoNLL.conll2dict(input_file, input_str, ignore_gapping, zip_file=zip_file)
return Document(doc_dict, text=None, comments=doc_comments)

@staticmethod
def convert_dict(doc_dict):
""" Convert the dictionary format input data to the CoNLL-U format output data. This is the reverse function of
`convert_conll`.
Input: dictionary format data, which is a list of list of dictionaries for each token in each sentence in the data.
Output: CoNLL-U format data, which is a list of list of list for each token in each sentence in the data.
TODO: remove in the next release
"""
doc = Document(doc_dict)
doc_conll = CoNLL.doc2conll(doc, include_comments=False)
doc_conll = [[x.split("\t") for x in sentence] for sentence in doc_conll]
warnings.warn('convert_dict is deprecated. Please use "{:C}".format(doc) and use the text format directly', stacklevel=2)
return doc_conll

@staticmethod
def conll_as_string(doc):
"""
Dump the loaded CoNLL-U format list data to string.
TODO: remove in the next release
"""
return_string = ""
for sent in doc:
for ln in sent:
return_string += ("\t".join(ln)+"\n")
return_string += "\n"
warnings.warn('conll_as_string is deprecated. Please use "{:C}".format(doc) and use the text format directly', stacklevel=2)
return return_string

@staticmethod
def dict2conll(doc_dict, filename):
"""
Expand All @@ -153,35 +121,6 @@ def dict2conll(doc_dict, filename):
CoNLL.write_doc2conll(doc, filename)


@staticmethod
def doc2conll(doc, include_comments=True):
"""
Convert a Document object to a list of list of strings
Each sentence is represented by a list of strings: first the comments, then the converted tokens
TODO: remove in the next release
"""
doc_conll = []
for sentence in doc.sentences:
sent_conll = list(sentence.comments) if include_comments else []
for token in sentence.tokens:
sent_conll.extend(token.to_conll_text().split("\n"))
doc_conll.append(sent_conll)

warnings.warn('doc2conll is deprecated. Please use "{:C}".format(doc) and use the text format directly', stacklevel=2)
return doc_conll

@staticmethod
def doc2conll_text(doc):
"""
Convert a Document to a big block of text.
TODO: remove in the next release
"""
warnings.warn('doc2conll_text is deprecated. Please use "{:C}".format(doc)', stacklevel=2)
return "{:C}".format(doc)

@staticmethod
def write_doc2conll(doc, filename, mode='w', encoding='utf-8'):
"""
Expand Down

0 comments on commit e01650f

Please sign in to comment.