Skip to content

Commit

Permalink
ID объектов в выводе
Browse files Browse the repository at this point in the history
Добавил ID объектов в вывод компаратора
  • Loading branch information
Stanislav Dzhumaev authored and Stanislav Dzhumaev committed Apr 1, 2016
1 parent 2f8b41b commit ea8ee75
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions scripts/dialent/objects/entity.py
Expand Up @@ -54,6 +54,7 @@ def processAttributes(self):
def toInlineString(self):
"""Creates an inline description of this entity"""
res = self.tag.upper()
res += ' ' + str(self.id) if self.id != -1 else ''
res += ' [' + ', '.join([str(x) for x in self.attributes]) + ']'

return res
Expand Down
4 changes: 3 additions & 1 deletion scripts/dialent/objects/fact.py
Expand Up @@ -29,6 +29,7 @@ class Fact:
def __init__(self):
"""Initialize the object (use Fact.fromStandard/Fact.fromTest instead)"""
self.tag = ''
self.id = ''
self.arguments = []
self.has_easymode_modality = False
self.has_hardmode_difficulty = False
Expand All @@ -39,7 +40,7 @@ def toTestString(self):
+ [x.toTest() for x in self.arguments if not x.is_special]) + '\n'

def toInlineString(self):
res = '[ '
res = '[ ' + str(self.id) + ' '
if self.has_easymode_modality:
res += '(MODALITY) '
if self.has_hardmode_difficulty:
Expand All @@ -53,6 +54,7 @@ def toInlineString(self):
def _load_id_line(self, line):
"""Loads the first line of the fact description"""
parts = line.split(' ')
self.id = parts[0]
self.tag = parts[1].strip(' :\n\t\r').lower()

def canMatch(self, other):
Expand Down
4 changes: 3 additions & 1 deletion scripts/dialent/objects/tokenset.py
Expand Up @@ -115,4 +115,6 @@ def findParents(self, all_token_sets):
def toInlineString(self):
"""Make an inline representation using the tokensets interval"""
i = self.toInterval()
return self.tag.upper() + ' {} "{}"'.format(i, self.text[i.start:i.end+1])
return (self.tag.upper()
+ (' {}'.format(self.id) if self.id != -1 else '')
+ ' {} "{}"'.format(i, self.text[i.start:i.end+1]))
2 changes: 2 additions & 0 deletions scripts/dialent/standard.py
Expand Up @@ -268,6 +268,8 @@ def makeTokenSets(self, is_locorg_allowed=True):
[x for span in mention.spans for x in span.tokens],
key, self.text)

ts.id = mention.id

for span in mention.spans:
for token in span.tokens:
mark = Tables.getMark(ts.tag, span.tag)
Expand Down

0 comments on commit ea8ee75

Please sign in to comment.