Skip content under copyright
Browse files- generate.py +16 -0
generate.py
CHANGED
@@ -62,6 +62,21 @@ def get_paras():
|
|
62 |
|
63 |
root = tree.getroot()
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
for i, p in enumerate(root.findall(".//p")):
|
66 |
xml = ET.tostring(p, encoding="unicode")
|
67 |
text = get_text_content(p)
|
@@ -77,6 +92,7 @@ def get_paras():
|
|
77 |
"text": text,
|
78 |
"thml": xml,
|
79 |
"refs": refs,
|
|
|
80 |
"all-MiniLM-L6-v2": emb,
|
81 |
}
|
82 |
|
|
|
62 |
|
63 |
root = tree.getroot()
|
64 |
|
65 |
+
# Skip content with copyright restrictions
|
66 |
+
# The copyright statements aren’t consistent.
|
67 |
+
# The ones that contain the text "public domain" (case insensitive)
|
68 |
+
# or nothing at all should be safe.
|
69 |
+
try:
|
70 |
+
rights = root.find(".//DC.Rights").text
|
71 |
+
rights = re.sub(r"\s+", " ", rights)
|
72 |
+
except:
|
73 |
+
rights = None
|
74 |
+
|
75 |
+
if rights and 'public domain' not in rights.lower():
|
76 |
+
print(f"Skipped {filename} due to copyright: {rights}", file=log, flush=True)
|
77 |
+
continue
|
78 |
+
continue
|
79 |
+
|
80 |
for i, p in enumerate(root.findall(".//p")):
|
81 |
xml = ET.tostring(p, encoding="unicode")
|
82 |
text = get_text_content(p)
|
|
|
92 |
"text": text,
|
93 |
"thml": xml,
|
94 |
"refs": refs,
|
95 |
+
"rights": rights,
|
96 |
"all-MiniLM-L6-v2": emb,
|
97 |
}
|
98 |
|