add image
This commit is contained in:
parent
43ebd700bf
commit
608e34c05a
@ -2,7 +2,7 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="7d73eeac-bcfb-4439-a5bc-734bf782761e" name="Default" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/military_qa.py" beforeDir="false" afterPath="$PROJECT_DIR$/military_qa.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -23,14 +23,14 @@
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.edit">
|
||||
<counts>
|
||||
<entry key="py" value="14481" />
|
||||
<entry key="py" value="14658" />
|
||||
<entry key="txt" value="14" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.edit">
|
||||
<counts>
|
||||
<entry key="PLAIN_TEXT" value="14" />
|
||||
<entry key="Python" value="14481" />
|
||||
<entry key="Python" value="14658" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.open">
|
||||
@ -67,8 +67,8 @@
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/military_qa.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="903">
|
||||
<caret line="140" column="32" selection-start-line="140" selection-start-column="32" selection-end-line="140" selection-end-column="32" />
|
||||
<state relative-caret-position="4097">
|
||||
<caret line="451" column="16" selection-start-line="451" selection-start-column="16" selection-end-line="451" selection-end-column="16" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -76,7 +76,7 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/insert_data.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="79">
|
||||
<state relative-caret-position="107">
|
||||
<caret line="105" column="13" selection-start-line="105" selection-start-column="13" selection-end-line="105" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="e#0#9#0" expanded="true" />
|
||||
@ -110,6 +110,8 @@
|
||||
<find>pattern</find>
|
||||
<find>数量</find>
|
||||
<find>print</find>
|
||||
<find>parser_dict</find>
|
||||
<find>'n_weapon', 'n_attr', 'n_weapon', 'n_attr'</find>
|
||||
</findStrings>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
@ -125,10 +127,11 @@
|
||||
<option value="$PROJECT_DIR$/insert_data.py" />
|
||||
<option value="$PROJECT_DIR$/collect_data.py" />
|
||||
<option value="$PROJECT_DIR$/militarygraph.py" />
|
||||
<option value="$PROJECT_DIR$/military_qa.py" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" fullScreen="true">
|
||||
<component name="ProjectFrameBounds" extendedState="1">
|
||||
<option name="x" value="2" />
|
||||
<option name="y" value="23" />
|
||||
<option name="width" value="1680" />
|
||||
@ -175,7 +178,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Python.militarygraph">
|
||||
<component name="RunManager" selected="Python.military_qa">
|
||||
<configuration default="true" type="tests" factoryName="Attests">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
@ -279,6 +282,27 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="military_qa" type="PythonConfigurationType" factoryName="Python" temporary="true">
|
||||
<module name="military_graph" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/military_qa.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="militarygraph" type="PythonConfigurationType" factoryName="Python" temporary="true">
|
||||
<module name="military_graph" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
@ -305,9 +329,11 @@
|
||||
<item itemvalue="Python.drug_graph" />
|
||||
<item itemvalue="Python.militarygraph" />
|
||||
<item itemvalue="Python.insert_data" />
|
||||
<item itemvalue="Python.military_qa" />
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.military_qa" />
|
||||
<item itemvalue="Python.militarygraph" />
|
||||
<item itemvalue="Python.insert_data" />
|
||||
<item itemvalue="Python.data" />
|
||||
@ -329,7 +355,7 @@
|
||||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="0" width="1680" height="1050" extended-state="0" />
|
||||
<frame x="2" y="23" width="1680" height="971" extended-state="1" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.0596745" />
|
||||
@ -337,7 +363,7 @@
|
||||
<window_info id="Favorites" order="2" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.6765306" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.80714285" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
@ -375,16 +401,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/insert_data.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="79">
|
||||
<caret line="105" column="13" selection-start-line="105" selection-start-column="13" selection-end-line="105" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="e#0#9#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/militarygraph.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2758">
|
||||
@ -405,10 +421,20 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/insert_data.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="107">
|
||||
<caret line="105" column="13" selection-start-line="105" selection-start-column="13" selection-end-line="105" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="e#0#9#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/military_qa.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="903">
|
||||
<caret line="140" column="32" selection-start-line="140" selection-start-column="32" selection-end-line="140" selection-end-column="32" />
|
||||
<state relative-caret-position="4097">
|
||||
<caret line="451" column="16" selection-start-line="451" selection-start-column="16" selection-end-line="451" selection-end-column="16" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
BIN
image/example1.png
Normal file
BIN
image/example1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 475 KiB |
@ -337,14 +337,14 @@ class MilitaryGraph:
|
||||
parser_dict['n_units'] = [wd for wd,flag in wds if flag == 'n_unit']
|
||||
parser_dict['n_weapons'] = [wd for wd,flag in wds if flag == 'n_weapon']
|
||||
parser_dict['pattern'] = [flag for wd, flag in wds if flag in ['n_attr', 'n_time', 'n_big', 'n_small', 'n_unit', 'n_country', 'n_compare', 'n_most', 'n_weapon']]
|
||||
parser_dict['wds'] = wds
|
||||
# parser_dict['wds'] = wds
|
||||
return parser_dict
|
||||
|
||||
'''答案搜索'''
|
||||
def search_answer(self, parser_dict):
|
||||
print(parser_dict)
|
||||
print('step1:问句解析 >>', parser_dict)
|
||||
pattern = parser_dict['pattern']
|
||||
print(pattern)
|
||||
print('step2:查询模板 >>',pattern)
|
||||
search_data = []
|
||||
condition = {}
|
||||
targets = ['名称']
|
||||
@ -425,6 +425,7 @@ class MilitaryGraph:
|
||||
['n_country','n_weapon', 'n_attr', 'n_weapon', 'n_attr'],
|
||||
['n_country','n_weapon', 'n_attr', 'n_country','n_weapon', 'n_attr'],
|
||||
['n_weapon', 'n_attr', 'n_attr', 'n_weapon', 'n_attr'],
|
||||
['n_weapon', 'n_attr', 'n_attr', 'n_weapon', 'n_attr', 'n_attr'],
|
||||
['n_country','n_weapon', 'n_attr', 'n_attr', 'n_weapon', 'n_attr'],
|
||||
['n_country','n_weapon', 'n_attr', 'n_country',' n_weapon', 'n_attr', 'n_attr'],
|
||||
['n_country','n_weapon', 'n_attr', 'n_attr', 'n_weapon', 'n_attr', 'n_attr'],
|
||||
@ -438,8 +439,8 @@ class MilitaryGraph:
|
||||
n_weapons = [self.weapon_dict.get(weapon) for weapon in parser_dict.get('n_weapons')]
|
||||
n1_weapon = n_weapons[0]
|
||||
n2_weapon = n_weapons[1]
|
||||
targets1 = [self.attribute_dict.get(weapon) for indx, weapon in enumerate(parser_dict.get('n_attrs')) if indx < len(n_indxes)]
|
||||
targets2 = [self.attribute_dict.get(weapon) for indx, weapon in enumerate(parser_dict.get('n_attrs')) if indx >= len(n_indxes)]
|
||||
targets1 = [self.attribute_dict.get(weapon) for indx, weapon in enumerate(parser_dict.get('n_attrs')) if indx < n_indxes[1]-1]
|
||||
targets2 = [self.attribute_dict.get(weapon) for indx, weapon in enumerate(parser_dict.get('n_attrs')) if indx >= n_indxes[1]-1]
|
||||
condition1 = {'名称': n1_weapon}
|
||||
condition2 = {'名称': n2_weapon}
|
||||
search_data.append({'condition':condition1, 'targets': targets1})
|
||||
@ -578,10 +579,9 @@ class MilitaryGraph:
|
||||
parser_dict = self.question_parser(question)
|
||||
results = self.search_answer(parser_dict)
|
||||
if results == [[]]:
|
||||
print('sorry, do not know the answer yet...')
|
||||
print('小勇:对不起,目前暂时还无法回答此类问题...')
|
||||
else:
|
||||
print('find %s result:'% len(results))
|
||||
print('answer detail:')
|
||||
print('小勇:共找到%s个答案, 下面是具体明细:'% len(results))
|
||||
for result in results:
|
||||
print(result)
|
||||
return
|
||||
@ -589,5 +589,5 @@ class MilitaryGraph:
|
||||
if __name__ == '__main__':
|
||||
handler = MilitaryGraph()
|
||||
while 1:
|
||||
question = input("enter an question to parser:\n")
|
||||
question = input("用户:").strip()
|
||||
handler.qa_main(question)
|
Loading…
Reference in New Issue
Block a user