# Copyright (c) 2020 EyeOnText, All Rights Reserved. # NOTICE: All information contained herein is, and remains the property of EyeOnText. from eot.wowool.native import Language, Domain from eot.wowool.annotation import Concept from eot.wowool.error import Error try: dutch = Language("dutch") entities = Domain("dutch-entity") doc = dutch("Jan Van Den Berg werkte als hoofdarts bij Omega Pharma.") doc = entities(doc) # filter some concepts requested_concepts = set(["Person", "Position", "Company"]) concept_filter = lambda concept: concept.uri in requested_concepts for concept in Concept.iter(doc.analysis, concept_filter): print(f"literal: {concept.literal:<20}, stem={concept.stem}") # flatten concepts into dict print("-" * 40) for concept in Concept.iter(doc.analysis, concept_filter): print({**concept}) print("-" * 40) for person in Concept.iter(doc.analysis, lambda concept: concept.uri == "Person"): for person_parts in Concept.iter( person, lambda concept: concept.uri.startswith("Person")): print( f"Person: {person_parts.uri:<20}, stem={person_parts.literal}")
# Copyright (c) 2020 EyeOnText, All Rights Reserved. # NOTICE: All information contained herein is, and remains the property of EyeOnText. from eot.wowool.native import Language, Domain from eot.wowool.error import Error try: english = Language("english") entities = Domain("english-entity") doc = english( "John Smith was in London on the 3/11/2020. He took a cab to the central station." ) doc = entities(doc) print('-' * 80) print(doc) except Error as ex: print("Exception:", ex)
"from": { "uri": "USER" }, "to": { "slot": "Document", "label": "Document" }, "relation": { "label": "Mentions" } }] } # fmt: on try: english = Language("dutch") entities = Domain("dutch-entity") myrule = Domain(source=""" rule:{ 'user' '\:' {(<>)+}=USER }; """) doc = english( "user:John \n\nJan Van Den Berg werkte als hoofdarts bij Omega Pharma." ) doc = entities(doc) doc = myrule(doc) graphit = EntityGraph(graph_config) graphit.slots["Document"] = {"data": "hello"} doc = graphit(doc) results = doc.entity_graph.merge() print('-' * 80) print(f'relations : {results.headers}')
import streamlit as st from eot.wowool.native import Language, Domain from eot.wowool.topic_identifier import TopicIdentifier from eot.wowool.annotation import Concept import pandas as pd entity_filter = set(["Person", "Company", "Address", "City", "Facility"]) st.write("EyeOnText English Topics and Entities") name = st.text_area("Enter Your text", """John Smith works at EyeOnText in Antwerp.""") if st.button("Analyze"): input_text = name analyzer = Language("english") entities = Domain("english-entity") topicit = TopicIdentifier(language="english") doc = entities(analyzer(input_text)) topics = topicit.get_topics(doc, 20) # st.write("topics") # st.write(pd.DataFrame(topics, columns=["topic", "relevancy"])) combined_topics = {} for topic in topics: combined_topics[topic[0]] = ["topic", topic[0], topic[1]] for concept in Concept.iter(doc, lambda concept: concept.uri in entity_filter): combined_topics[concept.literal] = [concept.uri, concept.literal, 1.0]
# Copyright (c) 2020 EyeOnText, All Rights Reserved. # NOTICE: All information contained herein is, and remains the property of EyeOnText. from eot.wowool.native import Language, Domain from eot.wowool.error import Error from eot.wowool.annotation import Concept from eot.wowool.annotation import Token try: analyzer = Language("swedish") rule_source = """ // Compound Sample: // capture all the word with verzekering lexicon:(input="component"){ försäkring } = INSURANCE_COMPONENT; // capture only the real verzekering not verzekeringsmaatschapijen lexicon:(input="head"){ försäkring } = INSURANCE_HEAD; // capture the cost of the insurance. rule:{ {h'försäkring'} = INSURANCE_TYPE { Num +currency } = INSURANCE_PRICE }; """ compounds = Domain(source=rule_source) input = "Det finns försäkringsbolag 40000 euro och försäkring: bilförsäkring 100 euro, cykelförsäkring 200 SEK " doc = compounds(analyzer(input)) print(doc) print("-" * 80) print(rule_source) print("-" * 80)