This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pip install unstructured[pdf] | |
| from langchain_community.document_loaders import OnlinePDFLoader | |
| loader = OnlinePDFLoader("https://arxiv.org/pdf/2302.03803.pdf") | |
| data = loader.load() #took 1-2 secs | |
| for doc in data: | |
| print(doc.type, """ | |
| metadata""", doc.metadata, """ | |
| length""", len(doc.page_content),""" | |
| content... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.function.Predicate; | |
| import java.util.function.UnaryOperator; | |
| import java.util.stream.IntStream; | |
| /** | |
| * Checks if a String is a palindrome (stripping special characters from it first). | |
| */ | |
| public class PalindromePredicate implements Predicate<String> { | |
| UnaryOperator<String> clean = str -> str.replaceAll("\\W", "").toLowerCase(); | |
| Predicate<String> isPalindrome = str -> IntStream.range(0, str.length() / 2) |