mirror of
https://github.com/agentuniverse-ai/agentUniverse.git
synced 2026-02-09 01:59:19 +08:00
refactor: mv DocumentClassifier to third party dir
This commit is contained in:
7
examples/third_party_examples/__init__.py
Normal file
7
examples/third_party_examples/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# !/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
# @Time : 2025/10/30 19:40
|
||||
# @Author : jerry.zzw
|
||||
# @Email : jerry.zzw@antgroup.com
|
||||
# @FileName: __init__.py.py
|
||||
7
examples/third_party_examples/tools/__init__.py
Normal file
7
examples/third_party_examples/tools/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# !/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
# @Time : 2025/10/30 19:40
|
||||
# @Author : jerry.zzw
|
||||
# @Email : jerry.zzw@antgroup.com
|
||||
# @FileName: __init__.py.py
|
||||
@@ -43,7 +43,7 @@ python test_classifier.py
|
||||
|
||||
```python
|
||||
from agentuniverse.agent.action.knowledge.store.document import Document
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.document_classifier import DocumentClassifier
|
||||
from examples.third_party_examples.tools.document_classifier_tool.document_classifier import DocumentClassifier
|
||||
|
||||
# 创建分类器
|
||||
classifier = DocumentClassifier()
|
||||
@@ -67,7 +67,8 @@ print(f"置信度: {classified_doc.metadata['classification_confidence']}")
|
||||
### 中文分类器使用
|
||||
|
||||
```python
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.chinese_document_classifier import ChineseDocumentClassifier
|
||||
from examples.third_party_examples.tools.document_classifier_tool.chinese_document_classifier import
|
||||
ChineseDocumentClassifier
|
||||
|
||||
# 创建中文分类器
|
||||
classifier = ChineseDocumentClassifier()
|
||||
@@ -8,14 +8,11 @@
|
||||
|
||||
import jieba
|
||||
import re
|
||||
from typing import List, Optional, Dict, Any
|
||||
from typing import List, Dict, Any
|
||||
from collections import Counter
|
||||
|
||||
from agentuniverse.agent.action.knowledge.store.query import Query
|
||||
from agentuniverse.agent.action.knowledge.store.document import Document
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.document_classifier import (
|
||||
DocumentClassifier,
|
||||
ClassificationStrategy
|
||||
from examples.third_party_examples.tools.document_classifier_tool.document_classifier import (
|
||||
DocumentClassifier
|
||||
)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ DocumentClassifier是agentUniverse框架中的文档分类组件,提供智能
|
||||
|
||||
```python
|
||||
from agentuniverse.agent.action.knowledge.store.document import Document
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.document_classifier import DocumentClassifier
|
||||
from examples.third_party_examples.tools.document_classifier_tool.document_classifier import DocumentClassifier
|
||||
|
||||
# 创建分类器
|
||||
classifier = DocumentClassifier()
|
||||
@@ -41,7 +41,8 @@ classified_doc = classifier._classify_document(doc)
|
||||
### 中文分类器
|
||||
|
||||
```python
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.chinese_document_classifier import ChineseDocumentClassifier
|
||||
from examples.third_party_examples.tools.document_classifier_tool.chinese_document_classifier import
|
||||
ChineseDocumentClassifier
|
||||
|
||||
# 创建中文分类器
|
||||
classifier = ChineseDocumentClassifier()
|
||||
@@ -21,11 +21,11 @@ import os
|
||||
from typing import List
|
||||
|
||||
# 添加项目根目录到Python路径
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..'))
|
||||
|
||||
from agentuniverse.agent.action.knowledge.store.document import Document
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.document_classifier import DocumentClassifier
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.chinese_document_classifier import ChineseDocumentClassifier
|
||||
from examples.third_party_examples.tools.document_classifier_tool.document_classifier import DocumentClassifier
|
||||
from examples.third_party_examples.tools.document_classifier_tool.chinese_document_classifier import ChineseDocumentClassifier
|
||||
|
||||
|
||||
def create_sample_documents() -> List[Document]:
|
||||
@@ -9,7 +9,7 @@ import sys
|
||||
import os
|
||||
|
||||
# 添加项目根目录到Python路径
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..'))
|
||||
|
||||
if __name__ == "__main__":
|
||||
from document_classifier_demo import main
|
||||
@@ -21,14 +21,14 @@ import sys
|
||||
import os
|
||||
|
||||
# 添加项目根目录到Python路径
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..'))
|
||||
|
||||
from agentuniverse.agent.action.knowledge.store.document import Document
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.document_classifier import (
|
||||
from examples.third_party_examples.tools.document_classifier_tool.document_classifier import (
|
||||
DocumentClassifier,
|
||||
ClassificationStrategy
|
||||
)
|
||||
from agentuniverse.agent.action.knowledge.doc_processor.chinese_document_classifier import ChineseDocumentClassifier
|
||||
from examples.third_party_examples.tools.document_classifier_tool.chinese_document_classifier import ChineseDocumentClassifier
|
||||
|
||||
|
||||
class TestDocumentClassifier(unittest.TestCase):
|
||||
Reference in New Issue
Block a user