mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-03 12:07:36 +00:00
text-splitters[minor]: Added Haskell support in langchain.text_splitter module (#16191)
- **Description:** Haskell language support added in text_splitter module - **Dependencies:** No - **Twitter handle:** @nisargtr If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17. --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
@@ -571,7 +571,45 @@ class RecursiveCharacterTextSplitter(TextSplitter):
|
||||
" ",
|
||||
"",
|
||||
]
|
||||
|
||||
elif language == Language.HASKELL:
|
||||
return [
|
||||
# Split along function definitions
|
||||
"\nmain :: ",
|
||||
"\nmain = ",
|
||||
"\nlet ",
|
||||
"\nin ",
|
||||
"\ndo ",
|
||||
"\nwhere ",
|
||||
"\n:: ",
|
||||
"\n= ",
|
||||
# Split along type declarations
|
||||
"\ndata ",
|
||||
"\nnewtype ",
|
||||
"\ntype ",
|
||||
"\n:: ",
|
||||
# Split along module declarations
|
||||
"\nmodule ",
|
||||
# Split along import statements
|
||||
"\nimport ",
|
||||
"\nqualified ",
|
||||
"\nimport qualified ",
|
||||
# Split along typeclass declarations
|
||||
"\nclass ",
|
||||
"\ninstance ",
|
||||
# Split along case expressions
|
||||
"\ncase ",
|
||||
# Split along guards in function definitions
|
||||
"\n| ",
|
||||
# Split along record field declarations
|
||||
"\ndata ",
|
||||
"\n= {",
|
||||
"\n, ",
|
||||
# Split by the normal type of lines
|
||||
"\n\n",
|
||||
"\n",
|
||||
" ",
|
||||
"",
|
||||
]
|
||||
else:
|
||||
raise ValueError(
|
||||
f"Language {language} is not supported! "
|
||||
|
Reference in New Issue
Block a user