Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HouseHarmony Video demo code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
j2-caldwell
HouseHarmony Video demo code
Commits
836ad4fe
Commit
836ad4fe
authored
1 year ago
by
j2-caldwell
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
48fc9805
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
process_text.py
+24
-0
24 additions, 0 deletions
process_text.py
with
24 additions
and
0 deletions
process_text.py
0 → 100644
+
24
−
0
View file @
836ad4fe
import
sys
import
json
import
spacy
# Load the spaCy model
#nlp = spacy.load("en_core_web_md")
nlp
=
spacy
.
load
(
"
./services/nlp_service/minimal_model3
"
)
def
process_text
(
text
):
# Process the text with spaCy
doc
=
nlp
(
text
)
# Extract entities and other relevant information
entities
=
[{
"
text
"
:
entity
.
text
,
"
label
"
:
entity
.
label_
}
for
entity
in
doc
.
ents
]
return
entities
if
__name__
==
"
__main__
"
:
# Read the text from the command line argument
input_text
=
sys
.
argv
[
1
]
# Convert the input text from JSON string to dictionary
input_data
=
json
.
loads
(
input_text
)
# Process the text
processed_data
=
process_text
(
input_data
[
'
text
'
])
# Print the processed data as a JSON string to stdout
print
(
json
.
dumps
(
processed_data
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment