Hi! Is the table in a separate file, or in the same file?
At least if it is in the same file, one could consider to just detect the tags in the table.
Just being able to navigate by clicking the numbers would be a plus, but especially since the tags seem to be very similar, I would think that a navigating user would be just as happy to see the table (with some extra information) as seeing the drawing in this case. E.g. how do they decide if they want to check out 54 rather than 55 here?
That said, an attempt to do it could proceed as follows:
- Run regular diagram detect to detect known tags
- For each detected tag named ABC123 with id X, produce the sample “00 ABC123]”, also add a sample “00”.
- Run diagram detect in beta with pattern_mode=True, min_tokens=1 and entities=a{“sample”:sample, “id”: X}]
- The detections will now have names like “60 T-00XX”, but also “60”, “51” etc.
- Finally, for each detection of a single two-digit number “XX” with a corresponding pattern detection “XX <TAG>” and regular detection of “<TAG>”, take the box of XX and insert the data corresponding to the tag and make annotations accordingly.
Ola,
Thank you for your answers, I’ll be curious to try these steps myself. For the start how do I run the “diagram detect” program with the specified pattern modes. I am sure there is an API, a ready reference/guide will be very helpful indeed.
Regards
Alex
There is the cognite sdk documentation: https://cognite-sdk-python.readthedocs-hosted.com/en/latest/contextualization.html#engineering-diagrams
And the API docs: https://api-docs.cognite.com/20230101-beta/tag/Engineering-diagrams/operation/diagramDetect/
But it could be more thorough on how to use pattern_mode.
You need to use api_subversion=”beta” when creating your client_config, e.g.
creds = OAuthInteractive(
client_id=client_id,
scopes= f"https://{cluster}.cognitedata.com/.default"],
authority_url=authority_uri
)
client_config = ClientConfig(
client_name="my-special-client",
base_url=f"https://{cluster}.cognitedata.com",
project=project,
credentials=creds,
api_subversion="beta",
)
client = CogniteClient(client_config)
You would do something like
entities = n{"name": "CBP-BIQ-SBBQ-01", "id": 123}, ...]
file_external_id = "something"
detect_job = client.diagrams.detect(
file_references=e
FileReference(file_external_id=file_external_id, first_page=1, last_page=1),
],
entities=entities,
pattern_mode=False
)
detect_job_result = detect_job.result
sample_entities = n
{"sample": f"00 {entity0"name"]}", "id": entityd"id"]}
for entity in result "items"]t0]i"annotations"]
for entity in an"entities"] # Usually only one per annotation, if names are unique
] + <{"sample": "00", "id": 1}]
pattern_detect_job = client.diagrams.detect(
file_references=e
FileReference(file_external_id=file_external_id, first_page=1, last_page=1),
],
entities=sample_entities,
min_tokens=1,
pattern_mode=True
)
pattern_detect_result = pattern_detect_job.result
Awesome, let me give it a try next week!