Skip to content

Commit

Permalink
tidying up
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Sep 26, 2024
1 parent a75f6fb commit 4327d4f
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 369 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length=160
extend-ignore = E203
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

29 changes: 0 additions & 29 deletions appveyor.yml

This file was deleted.

17 changes: 7 additions & 10 deletions parserator/data_prep_utils.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

from builtins import open

import os
import sys

from lxml import etree

if sys.version < '3' :
if sys.version < "3":
from backports import csv
else :
else:
import csv


class TrainingData(object):
class TrainingData:
def __init__(self, xml=None, module=None):

if xml is not None:
Expand Down Expand Up @@ -43,10 +40,10 @@ def _sequence_to_xml(self, labeled_sequence):
for token, label in labeled_sequence:
component_xml = etree.Element(label)
component_xml.text = token
component_xml.tail = ' '
component_xml.tail = " "
sequence_xml.append(component_xml)

sequence_xml[-1].tail = ''
sequence_xml[-1].tail = ""

return sequence_xml

Expand All @@ -62,13 +59,13 @@ def _strip_formatting(self, xml):

def __iter__(self):
for sequence_xml in self.xml:
raw_text = etree.tostring(sequence_xml, method='text', encoding='unicode')
raw_text = etree.tostring(sequence_xml, method="text", encoding="unicode")
yield raw_text, self._xml_to_sequence(sequence_xml)


# writes a list of strings to a file
def list2file(string_list, filepath):
with open(filepath, 'w') as csvfile:
with open(filepath, "w") as csvfile:
writer = csv.writer(csvfile, doublequote=True, quoting=csv.QUOTE_MINIMAL)
for string in string_list:
writer.writerow([string])
Loading

0 comments on commit 4327d4f

Please sign in to comment.