-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP Auto tagger #2503
Closed
Closed
CP Auto tagger #2503
Changes from 65 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
ca483fe
Update imatrics.py
tcp-bhargav 8f942a8
Update imatrics.py
tcp-bhargav a6d9fd9
V2: Update imatrics.py
tcp-bhargav 3de0597
Update imatrics.py
tcp-bhargav 6a8ee9c
Update imatrics.py
tcp-bhargav 13af372
Update imatrics.py
cpemichalhorak 2396cbe
Update imatrics.py
tcp-bhargav fd6618f
Update imatrics.py
tcp-bhargav f73fcc3
Create semaphore.py
tcp-bhargav c88c82d
Update semaphore.py
tcp-bhargav 7755b40
Update semaphore.py
tcp-bhargav d388769
Create semaphore.py
tcp-bhargav ad38e5c
Create semaphore.py
tcp-bhargav 8a3caca
Update semaphore.py
tcp-bhargav e94651d
Update semaphore.py
tcp-bhargav 032d41d
Update semaphore.py
tcp-bhargav 1dff98c
Update semaphore.py
tcp-bhargav eaadbbb
Update semaphore.py
tcp-bhargav 171dc12
Update semaphore.py
tcp-bhargav 9f0843e
Update semaphore.py
tcp-bhargav 6dbe94e
Update semaphore.py
tcp-bhargav 0e30fca
Update semaphore.py
tcp-bhargav 19aaacf
Update __init__.py
tcp-bhargav c2f1cad
Update semaphore.py
tcp-bhargav ecd98be
Update semaphore.py
tcp-bhargav ca28e4e
Update semaphore.py
tcp-bhargav 5709de1
Update semaphore.py
tcp-bhargav 34a8797
Update semaphore.py
tcp-bhargav 8008907
Update semaphore.py
tcp-bhargav b98efbc
Update semaphore.py
tcp-bhargav e9eb9ac
Update semaphore.py
tcp-bhargav 40f8965
Update semaphore.py
tcp-bhargav 7f6bfff
Update semaphore.py
tcp-bhargav 938a5be
Update semaphore.py
tcp-bhargav 26facd8
Update semaphore.py
tcp-bhargav 8befa27
Update semaphore.py
tcp-bhargav a0b521e
Update semaphore.py
tcp-bhargav 4c37c6c
Update semaphore.py
tcp-bhargav f6cdb34
Update semaphore.py
tcp-bhargav 594914a
Update semaphore.py
tcp-bhargav 4e1866c
Update semaphore.py
tcp-bhargav 5a5b162
Update semaphore.py
tcp-bhargav 3cdb227
Update semaphore.py
tcp-bhargav 4fe741e
Update semaphore.py
tcp-bhargav 2620807
Update semaphore.py
tcp-bhargav 07be371
Update imatrics.py with Michal's Code
tcp-bhargav 0d26218
Update imatrics.py
cpemichalhorak 8ff2226
Update imatrics.py
cpemichalhorak c76f816
Update imatrics.py
cpemichalhorak 1c9036e
Update imatrics.py
cpemichalhorak 4552674
Update semaphore.py
tcp-bhargav 1dfb71c
Update imatrics.py
tcp-bhargav b8c73ba
Update semaphore.py
tcp-bhargav 7affaa6
Update semaphore.py
tcp-bhargav cf2b806
Update __init__.py
tcp-bhargav 1115db9
Update semaphore.py
tcp-bhargav 989d35a
Update semaphore.py
tcp-bhargav 5d45786
Update __init__.py
tcp-bhargav a01fbfd
Update ninjs_formatter.py
tcp-bhargav a581b73
Update semaphore.py
tcp-bhargav 503787c
Added Comments for better Reference..
tcp-bhargav 2e358de
Added Comments For Better Reference
tcp-bhargav a9c0144
Removed a couple print Statements.
tcp-bhargav 6b4457d
imatrics changes reverted.
tcp-bhargav 2a954db
Updated with modifications asked by Petr.
tcp-bhargav ce532de
Create cp_ninjs_formatter
tcp-bhargav 90277f4
Rename cp_ninjs_formatter to cp_ninjs_formatter.py
tcp-bhargav e23ada9
Update ninjs_formatter.py Reverted back to the Original.
tcp-bhargav 814ec1f
Update __init__.py -- Reverted to Original Code
tcp-bhargav c481e60
Update __init__.py with Create Tag in KMM Feature
tcp-bhargav 7aa421a
Update semaphore.py in Formatters to work with ninjs_formatter_2
tcp-bhargav 083e518
Update and rename cp_ninjs_formatter.py to ninjs_formatter_2.py
tcp-bhargav fbe407a
Update __init__.py. Changed ninjs_formatter import to ninjs_formatter_2
tcp-bhargav 1b635c2
Update ninjs_ftp_formatter.py to work with our ninjs_formatter_2
tcp-bhargav c6e8ff7
Update vocabularies.json
tcp-bhargav 86f8f82
Update semaphore.py
tcp-bhargav 3711753
Update ninjs_formatter_2.py
tcp-bhargav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
from superdesk.text_utils import get_text | ||
from .ninjs_formatter import NINJSFormatter | ||
from superdesk.text_checkers.ai.semaphore import Semaphore # Import the Semaphore integration class | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
class SemaphoreFormatter(NINJSFormatter): | ||
def can_format(self, format_type, article): | ||
return format_type.lower() == "semaphore" and article.get("type") == "text" | ||
|
||
def _transform_to_ninjs(self, article, subscriber, recursive=True): | ||
semaphore = Semaphore() # Initialize the Semaphore integration | ||
formatted_data = {} # Define how you want to format the data for Semaphore | ||
|
||
try: | ||
# Example: format the data | ||
formatted_data["uuid"] = article["guid"] | ||
formatted_data["headline"] = get_text(article["headline"]) | ||
# Add more formatting logic here | ||
|
||
except Exception as e: | ||
logger.error(f"Error formatting data for Semaphore: {str(e)}") | ||
formatted_data = {} # Return an empty dictionary in case of an error | ||
|
||
return formatted_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from flask import current_app, json | ||
|
||
from superdesk.publish import register_transmitter | ||
from superdesk.publish.publish_service import PublishService | ||
from superdesk.text_checkers.ai.semaphore import Semaphore # Import the Semaphore integration class | ||
|
||
class SemaphoreTransmitter(PublishService): | ||
def _transmit(self, queue_item, subscriber): | ||
semaphore = Semaphore(current_app) # Initialize the Semaphore integration | ||
item = json.loads(queue_item["formatted_item"]) | ||
# Modify this part to transmit the item using the Semaphore integration | ||
semaphore.transmit(item) | ||
|
||
# Register the Semaphore transmitter | ||
register_transmitter("semaphore", SemaphoreTransmitter(), []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,13 @@ class AIResource(Resource): | |
"type": "dict", | ||
"required": True, | ||
"schema": { | ||
"guid": {"type": "string", "required": True}, | ||
"guid": {"type": "string", "required": False}, | ||
"abstract": {"type": "string", "required": False}, | ||
"language": {"type": "string", "required": True}, | ||
"headline": {"type": "string", "nullable": True}, | ||
"body_html": {"type": "string", "required": True}, | ||
"language": {"type": "string", "required": False}, | ||
"headline": {"type": "string", "nullable": False}, | ||
"slugline": {"type": "string", "required": False}, | ||
"searchString": {"type": "string", "required": False}, | ||
"body_html": {"type": "string", "required": False}, | ||
}, | ||
}, | ||
"tags": { | ||
|
@@ -88,7 +90,8 @@ def create(self, docs, **kwargs): | |
except KeyError: | ||
raise SuperdeskApiError.notFoundError("{service} service can't be found".format(service=service)) | ||
|
||
analyzed_data = service.analyze(item, doc.get("tags")) | ||
# analyzed_data = service.analyze(item, doc.get("tags")) | ||
analyzed_data = service.analyze(item) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would need the previous version here |
||
docs[0].update({"analysis": analyzed_data}) | ||
return [0] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to do those changes in a custom formatter, either that Semaphore one or some CP specific NINJS.
I think those changes would break some existing integrations like with newshub