Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -73,6 +73,15 @@ num_cores_Gliner_forDemo = 0 # 0 means use the GPU for Gliner !
|
|
73 |
tokenizerGliner = AutoTokenizer.from_pretrained('microsoft/deberta-v3-large')
|
74 |
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
encod = encoding_getter('microsoft/deberta-v3-large')
|
77 |
text_splitter = TokenTextSplitter(
|
78 |
# separators=separators,
|
@@ -219,7 +228,8 @@ def process_row_BioPortal_api(args, key_bioportal, row):
|
|
219 |
# choice = "NCBITAXON,NCBITaxon_"
|
220 |
elif choice.upper() == "NCBITaxon_":
|
221 |
choice = "NCBITAXON"
|
222 |
-
|
|
|
223 |
|
224 |
if onto_clauses and onto_clauses[-1] == ",":
|
225 |
onto_clauses=onto_clauses[:-1]
|
@@ -946,20 +956,24 @@ def getUrlBioAndAllOtherBioConcepts(word, args, key_virtuoso, cache_map_virtuoso
|
|
946 |
|
947 |
### this is for Bioportal url api:
|
948 |
onto_clauses = ""
|
|
|
949 |
for choice in args.KG_restriction:
|
950 |
-
if choice.upper() == "
|
951 |
-
choice
|
952 |
-
elif choice.upper() == "
|
953 |
-
choice = "
|
954 |
-
elif choice.upper() == "
|
955 |
-
choice = "
|
956 |
-
elif choice.upper() == "
|
957 |
-
choice = "
|
958 |
-
elif choice.upper() == "
|
959 |
-
choice = "
|
960 |
-
elif choice.upper() == "NCBITAXON":
|
961 |
-
|
962 |
-
|
|
|
|
|
|
|
963 |
|
964 |
if onto_clauses and onto_clauses[-1] == ",":
|
965 |
onto_clauses = onto_clauses[:-1]
|
@@ -1966,7 +1980,7 @@ def elinking(df_annotated_combined, text_splitter, args, key_geonames, cache_map
|
|
1966 |
|
1967 |
|
1968 |
|
1969 |
-
def nerBio(text, ModelsSelection, CategoriesSelection, ScoreFilt, EntityLinking, history_dict: dict):
|
1970 |
|
1971 |
if EntityLinking:
|
1972 |
EnableNEL="True"
|
@@ -2012,6 +2026,15 @@ def nerBio(text, ModelsSelection, CategoriesSelection, ScoreFilt, EntityLinking,
|
|
2012 |
|
2013 |
parser.add_argument("--temperature", type=int, default=0.01)
|
2014 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015 |
args = parser.parse_args()
|
2016 |
|
2017 |
|
|
|
73 |
tokenizerGliner = AutoTokenizer.from_pretrained('microsoft/deberta-v3-large')
|
74 |
|
75 |
|
76 |
+
POSSIBLE_KGchoices_List = ['AEO', 'BFO', 'BIM', 'BCGO', 'CL', 'CHIRO', 'CHEBI', 'DCM', 'FMA', 'GO', 'GENO',
|
77 |
+
'GeoSPARQL', 'HL7', 'DOID', 'HP', 'HP_O', 'IDO', 'IAO', 'ICD10', 'LOINC', 'MESH',
|
78 |
+
'MONDO', 'NCIT', 'NCBITAXON', 'NCBITaxon_', 'NIFCELL', 'NIFSTD', 'GML', 'OBCS', 'OCHV', 'OHPI',
|
79 |
+
'OPB', 'TRANS', 'PLOSTHES', 'RADLEX', 'RO', 'STY', 'SO', 'SNOMED', 'STATO',
|
80 |
+
'SYMP', 'FoodOn', 'UBERON', 'VO', 'EuroSciVoc']
|
81 |
+
|
82 |
+
ONLY_Ontologies_OnBIOPORTAL = ["AEO", "BCGO", "BFO", "BIM", "CHEBI", "CHIRO", "CL", "DCM", "DOID", "FMA", "FOODON", "GENO", "GML", "GO", "GEOSPARQL", "HL7", "HP", "HP_O", "IAO", "ICD10", "IDO", "LOINC", "MESH", "MONDO", "NCBITAXON", "NCIT", "NIFCELL", "NIFSTD", "OBCS", "OCHV", "OHPI", "OPB", "PLOSTHES", "RADLEX", "OBOREL", "SNOMEDCT", "SO", "STATO", "STY", "SYMP", "PTRANS", "UBERON", "VO"]
|
83 |
+
|
84 |
+
|
85 |
encod = encoding_getter('microsoft/deberta-v3-large')
|
86 |
text_splitter = TokenTextSplitter(
|
87 |
# separators=separators,
|
|
|
228 |
# choice = "NCBITAXON,NCBITaxon_"
|
229 |
elif choice.upper() == "NCBITaxon_":
|
230 |
choice = "NCBITAXON"
|
231 |
+
if choice in ONLY_Ontologies_OnBIOPORTAL:
|
232 |
+
onto_clauses=onto_clauses+choice+","
|
233 |
|
234 |
if onto_clauses and onto_clauses[-1] == ",":
|
235 |
onto_clauses=onto_clauses[:-1]
|
|
|
956 |
|
957 |
### this is for Bioportal url api:
|
958 |
onto_clauses = ""
|
959 |
+
|
960 |
for choice in args.KG_restriction:
|
961 |
+
if choice.upper() == "SNOMED":
|
962 |
+
choice="SNOMEDCT"
|
963 |
+
elif choice.upper() == "RO":
|
964 |
+
choice = "OBOREL"
|
965 |
+
elif choice.upper() == "TRANS":
|
966 |
+
choice = "PTRANS"
|
967 |
+
elif choice.upper() == "FoodOn":
|
968 |
+
choice = "FOODON"
|
969 |
+
elif choice.upper() == "GeoSPARQL":
|
970 |
+
choice = "GEOSPARQL"
|
971 |
+
# elif choice.upper() == "NCBITAXON":
|
972 |
+
# choice = "NCBITAXON,NCBITaxon_"
|
973 |
+
elif choice.upper() == "NCBITaxon_":
|
974 |
+
choice = "NCBITAXON"
|
975 |
+
if choice in ONLY_Ontologies_OnBIOPORTAL:
|
976 |
+
onto_clauses = onto_clauses + choice + ","
|
977 |
|
978 |
if onto_clauses and onto_clauses[-1] == ",":
|
979 |
onto_clauses = onto_clauses[:-1]
|
|
|
1980 |
|
1981 |
|
1982 |
|
1983 |
+
def nerBio(text, ModelsSelection, CategoriesSelection, ScoreFilt, EntityLinking, KGchoices, history_dict: dict):
|
1984 |
|
1985 |
if EntityLinking:
|
1986 |
EnableNEL="True"
|
|
|
2026 |
|
2027 |
parser.add_argument("--temperature", type=int, default=0.01)
|
2028 |
|
2029 |
+
#consose 20250205:
|
2030 |
+
#KGchoices = None
|
2031 |
+
# KGchoices = ['SNOMED', 'LOINC', 'ICD10', 'NCIT']
|
2032 |
+
#KGchoices = ['SNOMED', 'LOINC', 'ICD10', 'MESH', 'NCIT'] # restricts the input to these values only
|
2033 |
+
if KGchoices:
|
2034 |
+
KGchoices.sort()
|
2035 |
+
parser.add_argument("--KG_restriction", nargs='+', choices=KGchoices, default=KGchoices,
|
2036 |
+
help="List of ontologies to which restrict the entity linking task.")
|
2037 |
+
|
2038 |
args = parser.parse_args()
|
2039 |
|
2040 |
|