mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-11 07:50:47 +00:00
feat(text-splitters): add Visual Basic 6 support (#31173)
### **Description** Add Visual Basic 6 support. --- ### **Issue** No specific issue addressed. --- ### **Dependencies** No additional dependencies required. --------- Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
@@ -3043,6 +3043,82 @@ $csvContent | ForEach-Object {
|
||||
]
|
||||
|
||||
|
||||
FAKE_VISUALBASIC6_TEXT = """
|
||||
Option Explicit
|
||||
|
||||
Public Function SumTwoIntegers(ByVal a As Integer, ByVal b As Integer) As Integer
|
||||
SumTwoIntegers = a + b
|
||||
End Function
|
||||
|
||||
Public Sub Main()
|
||||
Dim i As Integer
|
||||
Dim limit As Integer
|
||||
|
||||
i = 0
|
||||
limit = 50
|
||||
|
||||
While i < limit
|
||||
i = SumTwoIntegers(i, 1)
|
||||
|
||||
If i = limit \\ 2 Then
|
||||
MsgBox "Halfway there! i = " & i
|
||||
End If
|
||||
Wend
|
||||
|
||||
MsgBox "Done! Final value of i: " & i
|
||||
End Sub
|
||||
"""
|
||||
|
||||
|
||||
def test_visualbasic6_code_splitter() -> None:
|
||||
splitter = RecursiveCharacterTextSplitter.from_language(
|
||||
Language.VISUALBASIC6,
|
||||
chunk_size=CHUNK_SIZE,
|
||||
chunk_overlap=0,
|
||||
)
|
||||
chunks = splitter.split_text(FAKE_VISUALBASIC6_TEXT)
|
||||
|
||||
assert chunks == [
|
||||
"Option Explicit",
|
||||
"Public Function",
|
||||
"SumTwoIntegers(",
|
||||
"ByVal",
|
||||
"a As Integer,",
|
||||
"ByVal b As",
|
||||
"Integer) As",
|
||||
"Integer",
|
||||
"SumTwoIntegers",
|
||||
"= a + b",
|
||||
"End Function",
|
||||
"Public Sub",
|
||||
"Main()",
|
||||
"Dim i As",
|
||||
"Integer",
|
||||
"Dim limit",
|
||||
"As Integer",
|
||||
"i = 0",
|
||||
"limit = 50",
|
||||
"While i <",
|
||||
"limit",
|
||||
"i =",
|
||||
"SumTwoIntegers(",
|
||||
"i,",
|
||||
"1)",
|
||||
"If i =",
|
||||
"limit \\ 2 Then",
|
||||
'MsgBox "Halfway',
|
||||
'there! i = " &',
|
||||
"i",
|
||||
"End If",
|
||||
"Wend",
|
||||
"MsgBox",
|
||||
'"Done! Final',
|
||||
'value of i: " &',
|
||||
"i",
|
||||
"End Sub",
|
||||
]
|
||||
|
||||
|
||||
def custom_iframe_extractor(iframe_tag: Any) -> str:
|
||||
iframe_src = iframe_tag.get("src", "")
|
||||
return f"[iframe:{iframe_src}]({iframe_src})"
|
||||
|
Reference in New Issue
Block a user