1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-02 10:31:00 +08:00

add parse method for summarization;

This commit is contained in:
Cadenza-Li
2023-05-31 00:08:21 +08:00
parent 55611aa43e
commit 74a5d7c8af
2 changed files with 40 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
import os
from pathlib import Path
from typing import Any, List
from qlib.typehint import Literal
@@ -60,6 +62,30 @@ class ActionTask(Task):
return "success"
class SummarizeTask(Task):
def execution(self) -> Any:
output_path = ''
def parse2txt(self, path) -> List:
file_list = []
path = Path.cwd().joinpath(path)
for root, dirs, files in os.walk(path):
for filename in files:
file_path = os.path.join(root, filename)
print(file_path)
file_list.append(file_path)
result = []
for file in file_list:
postfix = file.split('.')[-1]
if postfix in ['txt', 'py', 'log']:
with open(file) as f:
content = f.read()
print(content)
result.append({'postfix': postfix, 'content': content})
return result
class WorkflowManager:
"""This manange the whole task automation workflow including tasks and actions"""

View File

@@ -0,0 +1,14 @@
import unittest
from qlib.finco.task import SummarizeTask
class TestSummarize(unittest.TestCase):
def test_parse2txt(self):
task = SummarizeTask()
resp = task.parse2txt('')
print(resp)
if __name__ == '__main__':
unittest.main()