Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine text and page index #27

Merged
merged 3 commits into from Nov 13, 2020
Merged

Combine text and page index #27

merged 3 commits into from Nov 13, 2020

Conversation

emmadickson
Copy link
Contributor

@@ -8,7 +8,7 @@

HTML_MIME_TYPES = ("text/html", "application/xhtml", "application/xhtml+xml")

PAGE_INDEX = "text/pages.pdx"
PAGE_INDEX = "text/pages.jsonl"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change the directory to be pages/pages.jsonl

{"url": "https://example.com/", "title": "Example Domain": "text": "Example Domain\nThis domain is for..."}
{"url": "https://example.com/another", "title": "Another Example", "text": "Some other text for this page..."}
{"id": 0, "url": "https://example.com/", "title": "Example Domain": "text": "Example Domain\nThis domain is for..."}
{"id": 1, "url": "https://example.com/another", "title": "Another Example", "text": "Some other text for this page..."}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change examples to random id to match the new uuid?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UUID? This is nice! We sometimes use UUID V5 when we want to have a repeatable/always the same UUID based on a certain seed https://docs.python.org/3/library/uuid.html#uuid.uuid5 . By passing as first argument the constant uuid.NAMESPACE_URL and then your current "url" value as the second argument you get that. Does not change the actual string/sequence/pattern but allows you to always get a consistent, same UUID string when using the URL as seed, so maybe a future idea. Or also, just a comment you can totally dismiss because it may add processing time! and on a huge list that adds up! :) Happy you went this route. Good night!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that's an interesting idea, and tempting, but probably not a good idea, as this would imply that a URL or URL + TS are fully unique, which we can't guarantee. For example, we could have two captures of the same URL at same time that are different (different cookies, different locations, etc..), and this would imply that they're fixed.
Having a generic id string is also more flexible, as can import from systems that already have a page ID.

Maybe we should make it clear that the id is just a unique string, we're using uuid but it doesn't have to be that?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally! Makes sense, I thought URL were unique but of course they do not need to be like that. Thanks!!

if title:
data["title"] = title

if "text" in line:
data["text"] = line["text"]

yield json.dumps(data) + "\n"
id += 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed since its a uuid

@ikreymer ikreymer merged commit cab8a6d into webrecorder:master Nov 13, 2020
@emmadickson emmadickson deleted the text_index branch December 6, 2020 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants