Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13891

Problem with a list when I do edit it myself and not by a python package

$
0
0
from flair.data import Sentencefrom flair.models import SequenceTaggerfrom transformers import pipelineclass Klassensetzer:    def __init__(self):        self.tagger = SequenceTagger.load("flair/ner-german-large")        self.classifier = pipeline('sentiment-analysis')        self.content=None    def TK_model(self,content):        sentence = Sentence(content)        self.tagger.predict(sentence)        self.content=(sentence.get_spans('ner'))        return self.contentK=Klassensetzer()solu1=K.TK_model("Augustus besucht Berlin")#Means Augustus visits Berlinprint(solu1)#Output:         [Span[0:1]: "Augustus" → PER (1.0), Span[2:3]: "Berlin" → LOC (1.0)]#Does work outsolu2=[Span[0:1]: "Augustus" → PER (1.0), Span[2:3]: "Berlin" → LOC (1.0)]print(solu2)#Output:         SyntaxError: invalid syntax#Didn't worked out after the second use

I used the output to faster improve my code, but it didn't worked out.I used this python_package, but it takes to long to debug other things, so I just safed the output. The output given by the API is not a String, but a list, I could access the variables:

for i in solu2:     print(i)

I can't find my mistake.

When starting the following lines of code a second time, I tried to make shure these were the same I used the first time.

solu2=[Span[0:1]: "Augustus" → PER (1.0), Span[2:3]: "Berlin" → LOC (1.0)]print(solu2)#Output:         SyntaxError: invalid syntax

Look out for wether the output of the python_package is a string or not.

Thank you and I hope I didn't make a silly mistake


Viewing all articles
Browse latest Browse all 13891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>