Skip to content

Commit

Permalink
Merge pull request #138 from Capitains/issue-137
Browse files Browse the repository at this point in the history
Issue 137
  • Loading branch information
sonofmun committed Aug 21, 2017
2 parents a773e84 + 168ee35 commit 991792c
Show file tree
Hide file tree
Showing 6 changed files with 417 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2017-08-21 2.0.4 @ponteineptique

- Issue 137 : Fixed a bug where a passage extraction would not work even if the passage was found in the reff extraction. Origin of the issue was replacing too much .// in the xpath and thus breaking it

### 2017-06-16 2.0.3 @ponteineptique

- Issue 135 : Added support for empty namespace in string expansion for structured metadata"
Expand Down
2 changes: 1 addition & 1 deletion MyCapytain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"""

__version__ = "2.0.3"
__version__ = "2.0.4"
2 changes: 1 addition & 1 deletion MyCapytain/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def performXpath(parent, xpath):
loop = False
if xpath.startswith(".//"):
result = parent.xpath(
xpath.replace(".//", "./"),
xpath.replace(".//", "./", 1),
namespaces=XPATH_NAMESPACES
)
if len(result) == 0:
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/texts/local/commonTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_xml_with_xml_id(self):
self.assertIn(
'<l n="1" xml:id="C_l_1"><q><w lemma="ce2"',
text.getTextualNode(subreference="1.C_w_000001").export(Mimetypes.XML.TEI),
"Word chould be there !"
"Word should be there !"
)
self.assertEqual(
text.getReffs(level=2), [
Expand Down
29 changes: 29 additions & 0 deletions tests/test_ad_hoc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from unittest import TestCase
from MyCapytain.resources.texts.local.capitains.cts import CapitainsCtsText
from MyCapytain.common.constants import Mimetypes
from lxml import etree


class TestAdHoc(TestCase):
""" This is a series of tests drawn from issues on other repositories and third parties use of the code.
"""
def test_passage_extraction_fail_when_reffs_are_found(self):
""" This issues is drawn from https://github.com/PerseusDL/canonical-latinLit/issues/226
"""
with open("tests/testing_data/texts/extraction_issue.xml") as text:
interactive_text = CapitainsCtsText(resource=etree.parse(text).getroot())
reffs = interactive_text.getReffs(level=len(interactive_text.citation))
passages = []
# The failing passage was 5.1
for reff in reffs:
try:
passages.append(interactive_text.getTextualNode(reff))
except IndexError:
raise Exception("Unable to extract %s " % reff)

plaintext = [r.export(Mimetypes.PLAINTEXT, exclude=["tei:note"]).strip() for r in passages]
self.assertIn(
"NUNC et praedictos et regni sorte sequentes", plaintext,
"The text of 5.1 should be in plaintext"
)
Loading

0 comments on commit 991792c

Please sign in to comment.