Skip to content

Commit 8950f2c

Browse files
aradibhourahine
andauthored
Apply wording/spelling suggestions from code review
Co-authored-by: Ben Hourahine <benjamin.hourahine@strath.ac.uk>
1 parent ae55ce4 commit 8950f2c

6 files changed

Lines changed: 34 additions & 34 deletions

File tree

docs/hsd.rst

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ The HSD format
55
General description
66
===================
77

8-
You can think about the Human-readable Structured Data format as a pleasent
8+
You can think about the Human-readable Structured Data format as a pleasant
99
representation of a tree structure. It can represent a subset of what you
10-
can represent for example with XML. The following constraints with respect
10+
can do for example with XML. The following constraints compared
1111
to XML apply:
1212

13-
* Every node of a tree, which is not empty, can either contain further nodes
13+
* Every node of a tree, which is not empty, either contains further nodes
1414
or data, but never both.
1515

1616
* Every node may have a single (string) attribute only.
1717

1818
These constraints allow a very natural looking formatting of the data.
1919

20-
As an example, let's have a look at a data tree, which represents the input
21-
for a scientific software. In the XML representation, it could look as ::
20+
As an example, let's have a look at a data tree, which represents input
21+
for scientific software. In the XML representation, it could be written as ::
2222

2323
<Hamiltonian>
2424
<Dftb>
@@ -31,7 +31,7 @@ for a scientific software. In the XML representation, it could look as ::
3131
</Dftb>
3232
</Hamiltonian>
3333

34-
The same information can be encoded much more natural and compact in the HSD
34+
The same information can be encoded in a much more natural and compact form in HSD
3535
format as ::
3636

3737
Hamiltonian {
@@ -45,21 +45,21 @@ format as ::
4545
}
4646
}
4747

48-
The content of a node can be passed either between an opening and a closing
49-
curly brace or after an equal sign. In the latter case the end of the line will
48+
The content of a node are passed either between an opening and a closing
49+
curly brace or after an equals sign. In the latter case the end of the line will
5050
be the closing delimiter. The attribute (typically the unit of the data
51-
which a node contains) is specified between square brackets after
51+
which the node contains) is specified between square brackets after
5252
the node name.
5353

54-
The equal sign can not only be used to assign data as node content (provided
55-
the data fits into one line), but also to assign a single child node as content
54+
The equals sign can be used to assign data as a node content (provided
55+
the data fits into one line), or to assign a single child node as content
5656
for a given node. This leads to a compact and expressive notation for those
5757
cases, where (by the semantics of the input) a given node is only allowed to
5858
have a single child node as content. The tree above is a piece of a typical
5959
DFTB+ input, where only one child node is allowed for the nodes ``Hamiltonian``
60-
and ``Filling``, respectively. (They specify the type of the Hamiltonian
61-
and the filling function.) By making use of equal signs, the
62-
simplified HSD representation would look as compact as ::
60+
and ``Filling``, respectively (They specify the type of the Hamiltonian
61+
and the filling function). By making use of equals signs, the
62+
simplified HSD representation can be as compact as ::
6363

6464
Hamiltonian = Dftb {
6565
Scc = Yes
@@ -76,7 +76,7 @@ Mapping to dictionaries
7676

7777
Being basically a subset of XML, HSD data is best represented as an XML
7878
DOM-tree. However, very often a dictionary representation is more desirable,
79-
especially, when the language used to query and manipulate the tree offers
79+
especially when the language used to query and manipulate the tree offers
8080
dictionaries as primary data type (e.g. Python). The data in an HSD input
8181
can be easily represented with the help of nested dictionaries and lists. The
8282
input from the previous section would have the following representation as
@@ -99,8 +99,8 @@ Python dictionary (or as a JSON formatted input file)::
9999
The attribute of a node is stored under a special key containting the name of
100100
the node and the ``.attrib`` suffix.
101101

102-
One slight complication of the dictionary representation arrises in the case,
103-
when a given node has multiple child nodes with the same name, such as ::
102+
One slight complication of the dictionary representation arises in the case
103+
of node which has multiple child nodes with the same name ::
104104

105105
<ExternalField>
106106
<PointCharges>
@@ -179,12 +179,12 @@ to record following additional data for each HSD node:
179179
* the line, where the node was defined in the input (helpful for printing out
180180
informative error messages),
181181

182-
* the name of the HSD node as found in the input (useful if the tag names are
182+
* the name of the HSD node, as found in the input (useful if the tag names are
183183
converted to lower case to ease case-insensitive handling of the input) and
184184

185-
* whether an equal sign was used to open the block.
185+
* whether an equals sign was used to open the block.
186186

187-
If those information are asked to be recored, a special key with the
187+
If this information is being recorded, a special key with the
188188
``.hsdattrib`` suffix will be generated for each node in the dictionary/JSON
189189
presentation. The correpsonding value will be a dictionary with those
190190
information.
@@ -227,9 +227,9 @@ will yield the following dictionary representation of the input::
227227
}
228228

229229
The recorded line numbers can be used to issue helpful error messages with
230-
information about the line, where the user should search for the problem.
231-
The node names and the formatting information about the equal sign can ensure,
232-
that the formatting is similar to the original one, if the data is damped
230+
information about where the user should search for the problem.
231+
The node names and formatting information about the equal sign ensures
232+
that the formatting is similar to the original HSD, if the data is dumped
233233
into the HSD format again. Dumping the dictionary with ::
234234

235235
hsd.dump(inpdict, "test2-formatted.hsd", use_hsd_attribs=True)
@@ -244,13 +244,13 @@ would indeed yield ::
244244
}
245245

246246
which is basically identical with the original input. If the additional
247-
processing information is not recorded when the data is loaded or
247+
processing information is not recorded when the data is loaded, or
248248
it is not considered when the data is dumped as HSD again ::
249249

250250
inpdict = hsd.load("test.hsd", lower_tag_names=True)
251251
hsd.dump(inpdict, "test2-unformatted.hsd")
252252

253-
the resulting formatting will differ from the original form more::
253+
the resulting formatting will more strongly differ from the original HSD ::
254254

255255
hamiltonian {
256256
dftb {

docs/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ as possible (in contrast to XML and JSON) and is not indentation dependent (in
1111
contrast to YAML). It was developed originally as the input format for the
1212
scientific simulation tool (`DFTB+ <https://github.com/dftbplus/dftbplus>`_),
1313
but is of general purpose. Data stored in HSD can be easily mapped to a subset
14-
of JSON, YAML or XML and vica versa.
14+
of JSON, YAML or XML and *vice versa*.
1515

1616

1717
Installation

src/hsd/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def unquote(txt):
4040
# HSD attribute containing the line number
4141
HSD_ATTRIB_LINE = "line"
4242

43-
# HSD attribute marking that a node equals to its only child (instead of
43+
# HSD attribute marking that a node is equal to its only child (instead of
4444
# containing it)
4545
HSD_ATTRIB_EQUAL = "equal"
4646

src/hsd/eventhandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def add_text(self, text: str):
4646

4747

4848
class HsdEventPrinter(HsdEventHandler):
49-
"""Mininal demonstration class for event handlers.
49+
"""Minimal demonstration class for event handlers.
5050
5151
This specifc implemenation prints the events. Subclassing instances
5252
should override the public methods to customize its behavior.

src/hsd/io.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def load(hsdfile: Union[TextIO, str], lower_tag_names: bool = False,
3030
include_hsd_attribs: Whether the HSD-attributes (processing related
3131
attributes, like original tag name, line information, etc.) should
3232
be stored. Use it, if you wish to keep the formatting of the data
33-
on writing close to the original one (e.g. lowered tag names
34-
converted back to their original form, equal signs between parent
33+
close to the original on writing (e.g. lowered tag names
34+
converted back to their original form, equals signs between parent
3535
and only child kept, instead of converted to curly braces).
3636
flatten_data: Whether multiline data in the HSD input should be
3737
flattened into a single list. Othewise a list of lists is created,
@@ -70,8 +70,8 @@ def load_string(
7070
include_hsd_attribs: Whether the HSD-attributes (processing related
7171
attributes, like original tag name, line information, etc.) should
7272
be stored. Use it, if you wish to keep the formatting of the data
73-
on writing close to the original one (e.g. lowered tag names
74-
converted back to their original form, equal signs between parent
73+
close to the original one on writing (e.g. lowered tag names
74+
converted back to their original form, equals signs between parent
7575
and only child kept, instead of converted to curly braces).
7676
flatten_data: Whether multiline data in the HSD input should be
7777
flattened into a single list. Othewise a list of lists is created,

src/hsd/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ def __init__(self, eventhandler: Optional[HsdEventHandler] = None,
7979
self._has_child = True # Whether current node has a child already
8080
self._has_text = False # whether current node contains text already
8181
self._oldbefore = "" # buffer for tagname
82-
self._lower_tag_names = lower_tag_names # whether tag names should be lowered
82+
self._lower_tag_names = lower_tag_names # whether tag names should be lower cased
8383

8484

8585
def parse(self, fobj: Union[TextIO, str]):
86-
"""Parses the provided file like object.
86+
"""Parses the provided file-like object.
8787
8888
The parser will process the data and trigger the corresponding events
8989
in the eventhandler which was passed at initialization.

0 commit comments

Comments
 (0)