Skip to content

Commit edbda80

Browse files
committed
add read.Sentences
1 parent e6f22bf commit edbda80

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

udapi/block/read/conllu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def __init__(self, strict=False,
4646
# Maybe the code could be refactored, but it is speed-critical,
4747
# so benchmarking is needed because calling extra methods may result in slowdown.
4848
def read_tree(self, document=None):
49+
if self.filehandle is None:
50+
return None
51+
4952
root = Root()
5053
nodes = [root]
5154
parents = [0]
5255
comment = ''
53-
if self.filehandle is None:
54-
return None
55-
5656
mwts = []
5757
for line in self.filehandle:
5858
line = line.rstrip()

udapi/block/read/sentences.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Sentences class is a reader for plain-text sentences."""
2+
from udapi.core.basereader import BaseReader
3+
from udapi.core.root import Root
4+
5+
6+
class Sentences(BaseReader):
7+
"""A reader for plain-text sentences (one sentence per line) files."""
8+
9+
def read_tree(self, document=None):
10+
if self.filehandle is None:
11+
return None
12+
line = self.filehandle.readline()
13+
if line == '':
14+
return None
15+
root = Root()
16+
root.text = line.rstrip()
17+
return root

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy