Spaces:
Sleeping
Sleeping
File size: 3,452 Bytes
1fbcb0c fd97095 1fbcb0c 22a8e59 e7597b4 9b5b26a 1fbcb0c 22a8e59 1fbcb0c 22a8e59 8fe992b 1fbcb0c 22a8e59 1fbcb0c e7597b4 1fbcb0c e7597b4 1fbcb0c 18b6d8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
import nltk
from spacy.lang.en import English
# Example input: process description
process_description = """
The accounts payable team receives invoices via email.
They verify the invoice details, check for duplicates, and approve payment.
"""
# Preprocess the text
def preprocess_text(text):
tokenizer = English()
tokens = tokenizer(text)
processed_text = [token.lemma_ for token in tokens if not token.is_stop]
return ' '.join(processed_text)
processed_desc = preprocess_text(process_description)
print(processed_desc)
import spacy
nlp = spacy.load('en_core_web_sm')
def extract_entities(text):
doc = nlp(text)
entities = [(ent.text, ent.label_) for ent in doc.ents]
return entities
entities = extract_entities(process_description)
print("Extracted Entities:", entities)
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.svm import SVC
# Sample training data (simplified)
X = [
"receive invoices via email", # Automatable
"verify invoice details", # Automatable
"approve payment manually" # Non-automatable
]
y = [1, 1, 0]
# Feature extraction
vectorizer = TfidfVectorizer()
X_vec = vectorizer.fit_transform(X)
# Train a simple SVM
model = SVC()
model.fit(X_vec, y)
# Predict automation feasibility
def predict_automation_feasibility(text):
text_vec = vectorizer.transform([text])
return model.predict(text_vec)[0]
print(predict_automation_feasibility("check for duplicates")) # Output: 1 (Automatable)
# Example workflow for UiPath
def generate_uipath_workflow(tasks):
workflow = f"""
<Workflow [ContentUIVersion='1.0.0.0' TargetPlatform='.NETFramework,Version=v6.0' TargetRuntime='V6_0' HostRuntimeERO='255,255'>
<Variable Type='Object' Name='invoiceDetails' />
{''.join([f"<Variable Type='Object' Name='task_{task}' />" for task in tasks])}
<Sequence>
{''.join([f"<Activitysqueeze Code='GeneratedActivity严格落实任务_{task}' />" for task in tasks])}
</Sequence>
</Workflow>
"""
return workflow
tasks = ["receive_invoices", "verify_details", "approve_payment"]
workflow = generate_uipath_workflow(tasks)
print(workflow)
# Example workflow for UiPath
def generate_uipath_workflow(tasks):
workflow = f"""
<Workflow [ContentUIVersion='1.0.0.0' TargetPlatform='.NETFramework,Version=v6.0' TargetRuntime='V6_0' HostRuntimeERO='255,255'>
<Variable Type='Object' Name='invoiceDetails' />
{''.join([f"<Variable Type='Object' Name='task_{task}' />" for task in tasks])}
<Sequence>
{''.join([f"<Activitysqueeze Code='GeneratedActivity严格落实任务_{task}' />" for task in tasks])}
</Sequence>
</Workflow>
"""
return workflow
tasks = ["receive_invoices", "verify_details", "approve_payment"]
workflow = generate_uipath_workflow(tasks)
print(workflow)
# Example: Connect to UiPath Orchestrator API
import requests
def execute_workflow(workflow, uipath_uri, api_key):
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/xml"
}
response = requests.post(f"{uipath_uri}/api/workflows", headers=headers, data=workflow)
return response.json()
# Example API call
uipath_uri = "https://your-uipath-orchestrator-url"
api_key = "your-api-key"
response = execute_workflow(workflow, uipath_uri, api_key)
print("Workflow Execution Response:", response)
|