Enhance completions benchmark generator to extract words from a fallback Perl copyright file
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
from vastai import Worker, WorkerConfig, HandlerConfig, LogActionConfig, BenchmarkConfig
|
from vastai import Worker, WorkerConfig, HandlerConfig, LogActionConfig, BenchmarkConfig
|
||||||
|
|
||||||
@@ -22,9 +23,14 @@ def completions_benchmark_generator() -> dict:
|
|||||||
|
|
||||||
WORD_LIST = []
|
WORD_LIST = []
|
||||||
|
|
||||||
|
# Try to load from perl copyright file first
|
||||||
|
try:
|
||||||
|
with open("/usr/share/doc/perl/copyright", 'r') as f:
|
||||||
|
source_code = f.read()
|
||||||
|
WORD_LIST = re.findall(r'\b\w+\b', source_code)
|
||||||
|
except (FileNotFoundError, IOError):
|
||||||
|
# Fallback to loading from python file
|
||||||
with open(__file__, 'r') as f:
|
with open(__file__, 'r') as f:
|
||||||
# Use regex to extract words from the source code
|
|
||||||
import re
|
|
||||||
source_code = f.read()
|
source_code = f.read()
|
||||||
WORD_LIST = re.findall(r'\b\w+\b', source_code)
|
WORD_LIST = re.findall(r'\b\w+\b', source_code)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user